babylon.d.txt 2.8 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. export const Epsilon = 0.001;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  464. * @param convertedColor defines the Color3 object where to store the linear space version
  465. * @returns the unmodified Color3
  466. */
  467. toLinearSpaceToRef(convertedColor: Color3): Color3;
  468. /**
  469. * Computes a new Color3 converted from the current one to gamma space
  470. * @returns a new Color3 object
  471. */
  472. toGammaSpace(): Color3;
  473. /**
  474. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  475. * @param convertedColor defines the Color3 object where to store the gamma space version
  476. * @returns the unmodified Color3
  477. */
  478. toGammaSpaceToRef(convertedColor: Color3): Color3;
  479. private static _BlackReadOnly;
  480. /**
  481. * Creates a new Color3 from the string containing valid hexadecimal values
  482. * @param hex defines a string containing valid hexadecimal values
  483. * @returns a new Color3 object
  484. */
  485. static FromHexString(hex: string): Color3;
  486. /**
  487. * Creates a new Vector3 from the starting index of the given array
  488. * @param array defines the source array
  489. * @param offset defines an offset in the source array
  490. * @returns a new Color3 object
  491. */
  492. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  493. /**
  494. * Creates a new Color3 from integer values (< 256)
  495. * @param r defines the red component to read from (value between 0 and 255)
  496. * @param g defines the green component to read from (value between 0 and 255)
  497. * @param b defines the blue component to read from (value between 0 and 255)
  498. * @returns a new Color3 object
  499. */
  500. static FromInts(r: number, g: number, b: number): Color3;
  501. /**
  502. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  503. * @param start defines the start Color3 value
  504. * @param end defines the end Color3 value
  505. * @param amount defines the gradient value between start and end
  506. * @returns a new Color3 object
  507. */
  508. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  509. /**
  510. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  511. * @param left defines the start value
  512. * @param right defines the end value
  513. * @param amount defines the gradient factor
  514. * @param result defines the Color3 object where to store the result
  515. */
  516. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  517. /**
  518. * Returns a Color3 value containing a red color
  519. * @returns a new Color3 object
  520. */
  521. static Red(): Color3;
  522. /**
  523. * Returns a Color3 value containing a green color
  524. * @returns a new Color3 object
  525. */
  526. static Green(): Color3;
  527. /**
  528. * Returns a Color3 value containing a blue color
  529. * @returns a new Color3 object
  530. */
  531. static Blue(): Color3;
  532. /**
  533. * Returns a Color3 value containing a black color
  534. * @returns a new Color3 object
  535. */
  536. static Black(): Color3;
  537. /**
  538. * Gets a Color3 value containing a black color that must not be updated
  539. */
  540. static readonly BlackReadOnly: DeepImmutable<Color3>;
  541. /**
  542. * Returns a Color3 value containing a white color
  543. * @returns a new Color3 object
  544. */
  545. static White(): Color3;
  546. /**
  547. * Returns a Color3 value containing a purple color
  548. * @returns a new Color3 object
  549. */
  550. static Purple(): Color3;
  551. /**
  552. * Returns a Color3 value containing a magenta color
  553. * @returns a new Color3 object
  554. */
  555. static Magenta(): Color3;
  556. /**
  557. * Returns a Color3 value containing a yellow color
  558. * @returns a new Color3 object
  559. */
  560. static Yellow(): Color3;
  561. /**
  562. * Returns a Color3 value containing a gray color
  563. * @returns a new Color3 object
  564. */
  565. static Gray(): Color3;
  566. /**
  567. * Returns a Color3 value containing a teal color
  568. * @returns a new Color3 object
  569. */
  570. static Teal(): Color3;
  571. /**
  572. * Returns a Color3 value containing a random color
  573. * @returns a new Color3 object
  574. */
  575. static Random(): Color3;
  576. }
  577. /**
  578. * Class used to hold a RBGA color
  579. */
  580. export class Color4 {
  581. /**
  582. * Defines the red component (between 0 and 1, default is 0)
  583. */
  584. r: number;
  585. /**
  586. * Defines the green component (between 0 and 1, default is 0)
  587. */
  588. g: number;
  589. /**
  590. * Defines the blue component (between 0 and 1, default is 0)
  591. */
  592. b: number;
  593. /**
  594. * Defines the alpha component (between 0 and 1, default is 1)
  595. */
  596. a: number;
  597. /**
  598. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  599. * @param r defines the red component (between 0 and 1, default is 0)
  600. * @param g defines the green component (between 0 and 1, default is 0)
  601. * @param b defines the blue component (between 0 and 1, default is 0)
  602. * @param a defines the alpha component (between 0 and 1, default is 1)
  603. */
  604. constructor(
  605. /**
  606. * Defines the red component (between 0 and 1, default is 0)
  607. */
  608. r?: number,
  609. /**
  610. * Defines the green component (between 0 and 1, default is 0)
  611. */
  612. g?: number,
  613. /**
  614. * Defines the blue component (between 0 and 1, default is 0)
  615. */
  616. b?: number,
  617. /**
  618. * Defines the alpha component (between 0 and 1, default is 1)
  619. */
  620. a?: number);
  621. /**
  622. * Adds in place the given Color4 values to the current Color4 object
  623. * @param right defines the second operand
  624. * @returns the current updated Color4 object
  625. */
  626. addInPlace(right: DeepImmutable<Color4>): Color4;
  627. /**
  628. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  629. * @returns the new array
  630. */
  631. asArray(): number[];
  632. /**
  633. * Stores from the starting index in the given array the Color4 successive values
  634. * @param array defines the array where to store the r,g,b components
  635. * @param index defines an optional index in the target array to define where to start storing values
  636. * @returns the current Color4 object
  637. */
  638. toArray(array: number[], index?: number): Color4;
  639. /**
  640. * Determines equality between Color4 objects
  641. * @param otherColor defines the second operand
  642. * @returns true if the rgba values are equal to the given ones
  643. */
  644. equals(otherColor: DeepImmutable<Color4>): boolean;
  645. /**
  646. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  647. * @param right defines the second operand
  648. * @returns a new Color4 object
  649. */
  650. add(right: DeepImmutable<Color4>): Color4;
  651. /**
  652. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  653. * @param right defines the second operand
  654. * @returns a new Color4 object
  655. */
  656. subtract(right: DeepImmutable<Color4>): Color4;
  657. /**
  658. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  659. * @param right defines the second operand
  660. * @param result defines the Color4 object where to store the result
  661. * @returns the current Color4 object
  662. */
  663. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  664. /**
  665. * Creates a new Color4 with the current Color4 values multiplied by scale
  666. * @param scale defines the scaling factor to apply
  667. * @returns a new Color4 object
  668. */
  669. scale(scale: number): Color4;
  670. /**
  671. * Multiplies the current Color4 values by scale and stores the result in "result"
  672. * @param scale defines the scaling factor to apply
  673. * @param result defines the Color4 object where to store the result
  674. * @returns the current unmodified Color4
  675. */
  676. scaleToRef(scale: number, result: Color4): Color4;
  677. /**
  678. * Scale the current Color4 values by a factor and add the result to a given Color4
  679. * @param scale defines the scale factor
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the unmodified current Color4
  682. */
  683. scaleAndAddToRef(scale: number, result: Color4): Color4;
  684. /**
  685. * Clamps the rgb values by the min and max values and stores the result into "result"
  686. * @param min defines minimum clamping value (default is 0)
  687. * @param max defines maximum clamping value (default is 1)
  688. * @param result defines color to store the result into.
  689. * @returns the cuurent Color4
  690. */
  691. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  692. /**
  693. * Multipy an Color4 value by another and return a new Color4 object
  694. * @param color defines the Color4 value to multiply by
  695. * @returns a new Color4 object
  696. */
  697. multiply(color: Color4): Color4;
  698. /**
  699. * Multipy a Color4 value by another and push the result in a reference value
  700. * @param color defines the Color4 value to multiply by
  701. * @param result defines the Color4 to fill the result in
  702. * @returns the result Color4
  703. */
  704. multiplyToRef(color: Color4, result: Color4): Color4;
  705. /**
  706. * Creates a string with the Color4 current values
  707. * @returns the string representation of the Color4 object
  708. */
  709. toString(): string;
  710. /**
  711. * Returns the string "Color4"
  712. * @returns "Color4"
  713. */
  714. getClassName(): string;
  715. /**
  716. * Compute the Color4 hash code
  717. * @returns an unique number that can be used to hash Color4 objects
  718. */
  719. getHashCode(): number;
  720. /**
  721. * Creates a new Color4 copied from the current one
  722. * @returns a new Color4 object
  723. */
  724. clone(): Color4;
  725. /**
  726. * Copies the given Color4 values into the current one
  727. * @param source defines the source Color4 object
  728. * @returns the current updated Color4 object
  729. */
  730. copyFrom(source: Color4): Color4;
  731. /**
  732. * Copies the given float values into the current one
  733. * @param r defines the red component to read from
  734. * @param g defines the green component to read from
  735. * @param b defines the blue component to read from
  736. * @param a defines the alpha component to read from
  737. * @returns the current updated Color4 object
  738. */
  739. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  740. /**
  741. * Copies the given float values into the current one
  742. * @param r defines the red component to read from
  743. * @param g defines the green component to read from
  744. * @param b defines the blue component to read from
  745. * @param a defines the alpha component to read from
  746. * @returns the current updated Color4 object
  747. */
  748. set(r: number, g: number, b: number, a: number): Color4;
  749. /**
  750. * Compute the Color4 hexadecimal code as a string
  751. * @returns a string containing the hexadecimal representation of the Color4 object
  752. */
  753. toHexString(): string;
  754. /**
  755. * Computes a new Color4 converted from the current one to linear space
  756. * @returns a new Color4 object
  757. */
  758. toLinearSpace(): Color4;
  759. /**
  760. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  761. * @param convertedColor defines the Color4 object where to store the linear space version
  762. * @returns the unmodified Color4
  763. */
  764. toLinearSpaceToRef(convertedColor: Color4): Color4;
  765. /**
  766. * Computes a new Color4 converted from the current one to gamma space
  767. * @returns a new Color4 object
  768. */
  769. toGammaSpace(): Color4;
  770. /**
  771. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  772. * @param convertedColor defines the Color4 object where to store the gamma space version
  773. * @returns the unmodified Color4
  774. */
  775. toGammaSpaceToRef(convertedColor: Color4): Color4;
  776. /**
  777. * Creates a new Color4 from the string containing valid hexadecimal values
  778. * @param hex defines a string containing valid hexadecimal values
  779. * @returns a new Color4 object
  780. */
  781. static FromHexString(hex: string): Color4;
  782. /**
  783. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  784. * @param left defines the start value
  785. * @param right defines the end value
  786. * @param amount defines the gradient factor
  787. * @returns a new Color4 object
  788. */
  789. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  790. /**
  791. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  792. * @param left defines the start value
  793. * @param right defines the end value
  794. * @param amount defines the gradient factor
  795. * @param result defines the Color4 object where to store data
  796. */
  797. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  798. /**
  799. * Creates a new Color4 from a Color3 and an alpha value
  800. * @param color3 defines the source Color3 to read from
  801. * @param alpha defines the alpha component (1.0 by default)
  802. * @returns a new Color4 object
  803. */
  804. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  805. /**
  806. * Creates a new Color4 from the starting index element of the given array
  807. * @param array defines the source array to read from
  808. * @param offset defines the offset in the source array
  809. * @returns a new Color4 object
  810. */
  811. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  812. /**
  813. * Creates a new Color3 from integer values (< 256)
  814. * @param r defines the red component to read from (value between 0 and 255)
  815. * @param g defines the green component to read from (value between 0 and 255)
  816. * @param b defines the blue component to read from (value between 0 and 255)
  817. * @param a defines the alpha component to read from (value between 0 and 255)
  818. * @returns a new Color3 object
  819. */
  820. static FromInts(r: number, g: number, b: number, a: number): Color4;
  821. /**
  822. * Check the content of a given array and convert it to an array containing RGBA data
  823. * If the original array was already containing count * 4 values then it is returned directly
  824. * @param colors defines the array to check
  825. * @param count defines the number of RGBA data to expect
  826. * @returns an array containing count * 4 values (RGBA)
  827. */
  828. static CheckColors4(colors: number[], count: number): number[];
  829. }
  830. /**
  831. * Class representing a vector containing 2 coordinates
  832. */
  833. export class Vector2 {
  834. /** defines the first coordinate */
  835. x: number;
  836. /** defines the second coordinate */
  837. y: number;
  838. /**
  839. * Creates a new Vector2 from the given x and y coordinates
  840. * @param x defines the first coordinate
  841. * @param y defines the second coordinate
  842. */
  843. constructor(
  844. /** defines the first coordinate */
  845. x?: number,
  846. /** defines the second coordinate */
  847. y?: number);
  848. /**
  849. * Gets a string with the Vector2 coordinates
  850. * @returns a string with the Vector2 coordinates
  851. */
  852. toString(): string;
  853. /**
  854. * Gets class name
  855. * @returns the string "Vector2"
  856. */
  857. getClassName(): string;
  858. /**
  859. * Gets current vector hash code
  860. * @returns the Vector2 hash code as a number
  861. */
  862. getHashCode(): number;
  863. /**
  864. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  865. * @param array defines the source array
  866. * @param index defines the offset in source array
  867. * @returns the current Vector2
  868. */
  869. toArray(array: FloatArray, index?: number): Vector2;
  870. /**
  871. * Copy the current vector to an array
  872. * @returns a new array with 2 elements: the Vector2 coordinates.
  873. */
  874. asArray(): number[];
  875. /**
  876. * Sets the Vector2 coordinates with the given Vector2 coordinates
  877. * @param source defines the source Vector2
  878. * @returns the current updated Vector2
  879. */
  880. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  881. /**
  882. * Sets the Vector2 coordinates with the given floats
  883. * @param x defines the first coordinate
  884. * @param y defines the second coordinate
  885. * @returns the current updated Vector2
  886. */
  887. copyFromFloats(x: number, y: number): Vector2;
  888. /**
  889. * Sets the Vector2 coordinates with the given floats
  890. * @param x defines the first coordinate
  891. * @param y defines the second coordinate
  892. * @returns the current updated Vector2
  893. */
  894. set(x: number, y: number): Vector2;
  895. /**
  896. * Add another vector with the current one
  897. * @param otherVector defines the other vector
  898. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  899. */
  900. add(otherVector: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  903. * @param otherVector defines the other vector
  904. * @param result defines the target vector
  905. * @returns the unmodified current Vector2
  906. */
  907. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  908. /**
  909. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  910. * @param otherVector defines the other vector
  911. * @returns the current updated Vector2
  912. */
  913. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  916. * @param otherVector defines the other vector
  917. * @returns a new Vector2
  918. */
  919. addVector3(otherVector: Vector3): Vector2;
  920. /**
  921. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. subtract(otherVector: Vector2): Vector2;
  926. /**
  927. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  928. * @param otherVector defines the other vector
  929. * @param result defines the target vector
  930. * @returns the unmodified current Vector2
  931. */
  932. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  933. /**
  934. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  935. * @param otherVector defines the other vector
  936. * @returns the current updated Vector2
  937. */
  938. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  939. /**
  940. * Multiplies in place the current Vector2 coordinates by the given ones
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  947. * @param otherVector defines the other vector
  948. * @returns a new Vector2
  949. */
  950. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @param result defines the target vector
  955. * @returns the unmodified current Vector2
  956. */
  957. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  958. /**
  959. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  960. * @param x defines the first coordinate
  961. * @param y defines the second coordinate
  962. * @returns a new Vector2
  963. */
  964. multiplyByFloats(x: number, y: number): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. divide(otherVector: Vector2): Vector2;
  971. /**
  972. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Divides the current Vector2 coordinates by the given ones
  980. * @param otherVector defines the other vector
  981. * @returns the current updated Vector2
  982. */
  983. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  984. /**
  985. * Gets a new Vector2 with current Vector2 negated coordinates
  986. * @returns a new Vector2
  987. */
  988. negate(): Vector2;
  989. /**
  990. * Multiply the Vector2 coordinates by scale
  991. * @param scale defines the scaling factor
  992. * @returns the current updated Vector2
  993. */
  994. scaleInPlace(scale: number): Vector2;
  995. /**
  996. * Returns a new Vector2 scaled by "scale" from the current Vector2
  997. * @param scale defines the scaling factor
  998. * @returns a new Vector2
  999. */
  1000. scale(scale: number): Vector2;
  1001. /**
  1002. * Scale the current Vector2 values by a factor to a given Vector2
  1003. * @param scale defines the scale factor
  1004. * @param result defines the Vector2 object where to store the result
  1005. * @returns the unmodified current Vector2
  1006. */
  1007. scaleToRef(scale: number, result: Vector2): Vector2;
  1008. /**
  1009. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1010. * @param scale defines the scale factor
  1011. * @param result defines the Vector2 object where to store the result
  1012. * @returns the unmodified current Vector2
  1013. */
  1014. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1015. /**
  1016. * Gets a boolean if two vectors are equals
  1017. * @param otherVector defines the other vector
  1018. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1019. */
  1020. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1021. /**
  1022. * Gets a boolean if two vectors are equals (using an epsilon value)
  1023. * @param otherVector defines the other vector
  1024. * @param epsilon defines the minimal distance to consider equality
  1025. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1026. */
  1027. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1028. /**
  1029. * Gets a new Vector2 from current Vector2 floored values
  1030. * @returns a new Vector2
  1031. */
  1032. floor(): Vector2;
  1033. /**
  1034. * Gets a new Vector2 from current Vector2 floored values
  1035. * @returns a new Vector2
  1036. */
  1037. fract(): Vector2;
  1038. /**
  1039. * Gets the length of the vector
  1040. * @returns the vector length (float)
  1041. */
  1042. length(): number;
  1043. /**
  1044. * Gets the vector squared length
  1045. * @returns the vector squared length (float)
  1046. */
  1047. lengthSquared(): number;
  1048. /**
  1049. * Normalize the vector
  1050. * @returns the current updated Vector2
  1051. */
  1052. normalize(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 copied from the Vector2
  1055. * @returns a new Vector2
  1056. */
  1057. clone(): Vector2;
  1058. /**
  1059. * Gets a new Vector2(0, 0)
  1060. * @returns a new Vector2
  1061. */
  1062. static Zero(): Vector2;
  1063. /**
  1064. * Gets a new Vector2(1, 1)
  1065. * @returns a new Vector2
  1066. */
  1067. static One(): Vector2;
  1068. /**
  1069. * Gets a new Vector2 set from the given index element of the given array
  1070. * @param array defines the data source
  1071. * @param offset defines the offset in the data source
  1072. * @returns a new Vector2
  1073. */
  1074. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1075. /**
  1076. * Sets "result" from the given index element of the given array
  1077. * @param array defines the data source
  1078. * @param offset defines the offset in the data source
  1079. * @param result defines the target vector
  1080. */
  1081. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1082. /**
  1083. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1084. * @param value1 defines 1st point of control
  1085. * @param value2 defines 2nd point of control
  1086. * @param value3 defines 3rd point of control
  1087. * @param value4 defines 4th point of control
  1088. * @param amount defines the interpolation factor
  1089. * @returns a new Vector2
  1090. */
  1091. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1092. /**
  1093. * 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".
  1094. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1095. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1096. * @param value defines the value to clamp
  1097. * @param min defines the lower limit
  1098. * @param max defines the upper limit
  1099. * @returns a new Vector2
  1100. */
  1101. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1102. /**
  1103. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1104. * @param value1 defines the 1st control point
  1105. * @param tangent1 defines the outgoing tangent
  1106. * @param value2 defines the 2nd control point
  1107. * @param tangent2 defines the incoming tangent
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1114. * @param start defines the start vector
  1115. * @param end defines the end vector
  1116. * @param amount defines the interpolation factor
  1117. * @returns a new Vector2
  1118. */
  1119. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1120. /**
  1121. * Gets the dot product of the vector "left" and the vector "right"
  1122. * @param left defines first vector
  1123. * @param right defines second vector
  1124. * @returns the dot product (float)
  1125. */
  1126. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1127. /**
  1128. * Returns a new Vector2 equal to the normalized given vector
  1129. * @param vector defines the vector to normalize
  1130. * @returns a new Vector2
  1131. */
  1132. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1133. /**
  1134. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1135. * @param left defines 1st vector
  1136. * @param right defines 2nd vector
  1137. * @returns a new Vector2
  1138. */
  1139. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1140. /**
  1141. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1142. * @param left defines 1st vector
  1143. * @param right defines 2nd vector
  1144. * @returns a new Vector2
  1145. */
  1146. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1147. /**
  1148. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1149. * @param vector defines the vector to transform
  1150. * @param transformation defines the matrix to apply
  1151. * @returns a new Vector2
  1152. */
  1153. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1154. /**
  1155. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1156. * @param vector defines the vector to transform
  1157. * @param transformation defines the matrix to apply
  1158. * @param result defines the target vector
  1159. */
  1160. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1161. /**
  1162. * Determines if a given vector is included in a triangle
  1163. * @param p defines the vector to test
  1164. * @param p0 defines 1st triangle point
  1165. * @param p1 defines 2nd triangle point
  1166. * @param p2 defines 3rd triangle point
  1167. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1168. */
  1169. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1170. /**
  1171. * Gets the distance between the vectors "value1" and "value2"
  1172. * @param value1 defines first vector
  1173. * @param value2 defines second vector
  1174. * @returns the distance between vectors
  1175. */
  1176. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1177. /**
  1178. * Returns the squared distance between the vectors "value1" and "value2"
  1179. * @param value1 defines first vector
  1180. * @param value2 defines second vector
  1181. * @returns the squared distance between vectors
  1182. */
  1183. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1184. /**
  1185. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1186. * @param value1 defines first vector
  1187. * @param value2 defines second vector
  1188. * @returns a new Vector2
  1189. */
  1190. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1191. /**
  1192. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1193. * @param p defines the middle point
  1194. * @param segA defines one point of the segment
  1195. * @param segB defines the other point of the segment
  1196. * @returns the shortest distance
  1197. */
  1198. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1199. }
  1200. /**
  1201. * Classed used to store (x,y,z) vector representation
  1202. * A Vector3 is the main object used in 3D geometry
  1203. * It can represent etiher the coordinates of a point the space, either a direction
  1204. * Reminder: js uses a left handed forward facing system
  1205. */
  1206. export class Vector3 {
  1207. /**
  1208. * Defines the first coordinates (on X axis)
  1209. */
  1210. x: number;
  1211. /**
  1212. * Defines the second coordinates (on Y axis)
  1213. */
  1214. y: number;
  1215. /**
  1216. * Defines the third coordinates (on Z axis)
  1217. */
  1218. z: number;
  1219. private static _UpReadOnly;
  1220. /**
  1221. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1222. * @param x defines the first coordinates (on X axis)
  1223. * @param y defines the second coordinates (on Y axis)
  1224. * @param z defines the third coordinates (on Z axis)
  1225. */
  1226. constructor(
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x?: number,
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y?: number,
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z?: number);
  1239. /**
  1240. * Creates a string representation of the Vector3
  1241. * @returns a string with the Vector3 coordinates.
  1242. */
  1243. toString(): string;
  1244. /**
  1245. * Gets the class name
  1246. * @returns the string "Vector3"
  1247. */
  1248. getClassName(): string;
  1249. /**
  1250. * Creates the Vector3 hash code
  1251. * @returns a number which tends to be unique between Vector3 instances
  1252. */
  1253. getHashCode(): number;
  1254. /**
  1255. * Creates an array containing three elements : the coordinates of the Vector3
  1256. * @returns a new array of numbers
  1257. */
  1258. asArray(): number[];
  1259. /**
  1260. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1261. * @param array defines the destination array
  1262. * @param index defines the offset in the destination array
  1263. * @returns the current Vector3
  1264. */
  1265. toArray(array: FloatArray, index?: number): Vector3;
  1266. /**
  1267. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1268. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1269. */
  1270. toQuaternion(): Quaternion;
  1271. /**
  1272. * Adds the given vector to the current Vector3
  1273. * @param otherVector defines the second operand
  1274. * @returns the current updated Vector3
  1275. */
  1276. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1277. /**
  1278. * Adds the given coordinates to the current Vector3
  1279. * @param x defines the x coordinate of the operand
  1280. * @param y defines the y coordinate of the operand
  1281. * @param z defines the z coordinate of the operand
  1282. * @returns the current updated Vector3
  1283. */
  1284. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1285. /**
  1286. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1287. * @param otherVector defines the second operand
  1288. * @returns the resulting Vector3
  1289. */
  1290. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1293. * @param otherVector defines the second operand
  1294. * @param result defines the Vector3 object where to store the result
  1295. * @returns the current Vector3
  1296. */
  1297. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1298. /**
  1299. * Subtract the given vector from the current Vector3
  1300. * @param otherVector defines the second operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1304. /**
  1305. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1319. * @param x defines the x coordinate of the operand
  1320. * @param y defines the y coordinate of the operand
  1321. * @param z defines the z coordinate of the operand
  1322. * @returns the resulting Vector3
  1323. */
  1324. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1325. /**
  1326. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1327. * @param x defines the x coordinate of the operand
  1328. * @param y defines the y coordinate of the operand
  1329. * @param z defines the z coordinate of the operand
  1330. * @param result defines the Vector3 object where to store the result
  1331. * @returns the current Vector3
  1332. */
  1333. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1334. /**
  1335. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1336. * @returns a new Vector3
  1337. */
  1338. negate(): Vector3;
  1339. /**
  1340. * Multiplies the Vector3 coordinates by the float "scale"
  1341. * @param scale defines the multiplier factor
  1342. * @returns the current updated Vector3
  1343. */
  1344. scaleInPlace(scale: number): Vector3;
  1345. /**
  1346. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1347. * @param scale defines the multiplier factor
  1348. * @returns a new Vector3
  1349. */
  1350. scale(scale: number): Vector3;
  1351. /**
  1352. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1353. * @param scale defines the multiplier factor
  1354. * @param result defines the Vector3 object where to store the result
  1355. * @returns the current Vector3
  1356. */
  1357. scaleToRef(scale: number, result: Vector3): Vector3;
  1358. /**
  1359. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1360. * @param scale defines the scale factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the unmodified current Vector3
  1363. */
  1364. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1367. * @param otherVector defines the second operand
  1368. * @returns true if both vectors are equals
  1369. */
  1370. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1371. /**
  1372. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1373. * @param otherVector defines the second operand
  1374. * @param epsilon defines the minimal distance to define values as equals
  1375. * @returns true if both vectors are distant less than epsilon
  1376. */
  1377. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 coordinates equals the given floats
  1380. * @param x defines the x coordinate of the operand
  1381. * @param y defines the y coordinate of the operand
  1382. * @param z defines the z coordinate of the operand
  1383. * @returns true if both vectors are equals
  1384. */
  1385. equalsToFloats(x: number, y: number, z: number): boolean;
  1386. /**
  1387. * Multiplies the current Vector3 coordinates by the given ones
  1388. * @param otherVector defines the second operand
  1389. * @returns the current updated Vector3
  1390. */
  1391. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1392. /**
  1393. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1394. * @param otherVector defines the second operand
  1395. * @returns the new Vector3
  1396. */
  1397. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1398. /**
  1399. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1400. * @param otherVector defines the second operand
  1401. * @param result defines the Vector3 object where to store the result
  1402. * @returns the current Vector3
  1403. */
  1404. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1405. /**
  1406. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1407. * @param x defines the x coordinate of the operand
  1408. * @param y defines the y coordinate of the operand
  1409. * @param z defines the z coordinate of the operand
  1410. * @returns the new Vector3
  1411. */
  1412. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1413. /**
  1414. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones.
  1428. * @param otherVector defines the second operand
  1429. * @returns the current updated Vector3
  1430. */
  1431. divideInPlace(otherVector: Vector3): Vector3;
  1432. /**
  1433. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1434. * @param other defines the second operand
  1435. * @returns the current updated Vector3
  1436. */
  1437. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1440. * @param other defines the second operand
  1441. * @returns the current updated Vector3
  1442. */
  1443. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1446. * @param x defines the x coordinate of the operand
  1447. * @param y defines the y coordinate of the operand
  1448. * @param z defines the z coordinate of the operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1454. * @param x defines the x coordinate of the operand
  1455. * @param y defines the y coordinate of the operand
  1456. * @param z defines the z coordinate of the operand
  1457. * @returns the current updated Vector3
  1458. */
  1459. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1460. /**
  1461. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1462. * Check if is non uniform within a certain amount of decimal places to account for this
  1463. * @param epsilon the amount the values can differ
  1464. * @returns if the the vector is non uniform to a certain number of decimal places
  1465. */
  1466. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1467. /**
  1468. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1469. */
  1470. readonly isNonUniform: boolean;
  1471. /**
  1472. * Gets a new Vector3 from current Vector3 floored values
  1473. * @returns a new Vector3
  1474. */
  1475. floor(): Vector3;
  1476. /**
  1477. * Gets a new Vector3 from current Vector3 floored values
  1478. * @returns a new Vector3
  1479. */
  1480. fract(): Vector3;
  1481. /**
  1482. * Gets the length of the Vector3
  1483. * @returns the length of the Vecto3
  1484. */
  1485. length(): number;
  1486. /**
  1487. * Gets the squared length of the Vector3
  1488. * @returns squared length of the Vector3
  1489. */
  1490. lengthSquared(): number;
  1491. /**
  1492. * Normalize the current Vector3.
  1493. * Please note that this is an in place operation.
  1494. * @returns the current updated Vector3
  1495. */
  1496. normalize(): Vector3;
  1497. /**
  1498. * Reorders the x y z properties of the vector in place
  1499. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1500. * @returns the current updated vector
  1501. */
  1502. reorderInPlace(order: string): this;
  1503. /**
  1504. * Rotates the vector around 0,0,0 by a quaternion
  1505. * @param quaternion the rotation quaternion
  1506. * @param result vector to store the result
  1507. * @returns the resulting vector
  1508. */
  1509. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1510. /**
  1511. * Rotates a vector around a given point
  1512. * @param quaternion the rotation quaternion
  1513. * @param point the point to rotate around
  1514. * @param result vector to store the result
  1515. * @returns the resulting vector
  1516. */
  1517. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1518. /**
  1519. * Normalize the current Vector3 with the given input length.
  1520. * Please note that this is an in place operation.
  1521. * @param len the length of the vector
  1522. * @returns the current updated Vector3
  1523. */
  1524. normalizeFromLength(len: number): Vector3;
  1525. /**
  1526. * Normalize the current Vector3 to a new vector
  1527. * @returns the new Vector3
  1528. */
  1529. normalizeToNew(): Vector3;
  1530. /**
  1531. * Normalize the current Vector3 to the reference
  1532. * @param reference define the Vector3 to update
  1533. * @returns the updated Vector3
  1534. */
  1535. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1536. /**
  1537. * Creates a new Vector3 copied from the current Vector3
  1538. * @returns the new Vector3
  1539. */
  1540. clone(): Vector3;
  1541. /**
  1542. * Copies the given vector coordinates to the current Vector3 ones
  1543. * @param source defines the source Vector3
  1544. * @returns the current updated Vector3
  1545. */
  1546. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1547. /**
  1548. * Copies the given floats to the current Vector3 coordinates
  1549. * @param x defines the x coordinate of the operand
  1550. * @param y defines the y coordinate of the operand
  1551. * @param z defines the z coordinate of the operand
  1552. * @returns the current updated Vector3
  1553. */
  1554. copyFromFloats(x: number, y: number, z: number): Vector3;
  1555. /**
  1556. * Copies the given floats to the current Vector3 coordinates
  1557. * @param x defines the x coordinate of the operand
  1558. * @param y defines the y coordinate of the operand
  1559. * @param z defines the z coordinate of the operand
  1560. * @returns the current updated Vector3
  1561. */
  1562. set(x: number, y: number, z: number): Vector3;
  1563. /**
  1564. * Copies the given float to the current Vector3 coordinates
  1565. * @param v defines the x, y and z coordinates of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. setAll(v: number): Vector3;
  1569. /**
  1570. * Get the clip factor between two vectors
  1571. * @param vector0 defines the first operand
  1572. * @param vector1 defines the second operand
  1573. * @param axis defines the axis to use
  1574. * @param size defines the size along the axis
  1575. * @returns the clip factor
  1576. */
  1577. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1578. /**
  1579. * Get angle between two vectors
  1580. * @param vector0 angle between vector0 and vector1
  1581. * @param vector1 angle between vector0 and vector1
  1582. * @param normal direction of the normal
  1583. * @return the angle between vector0 and vector1
  1584. */
  1585. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1586. /**
  1587. * Returns a new Vector3 set from the index "offset" of the given array
  1588. * @param array defines the source array
  1589. * @param offset defines the offset in the source array
  1590. * @returns the new Vector3
  1591. */
  1592. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1593. /**
  1594. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1595. * This function is deprecated. Use FromArray instead
  1596. * @param array defines the source array
  1597. * @param offset defines the offset in the source array
  1598. * @returns the new Vector3
  1599. */
  1600. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1601. /**
  1602. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1603. * @param array defines the source array
  1604. * @param offset defines the offset in the source array
  1605. * @param result defines the Vector3 where to store the result
  1606. */
  1607. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1608. /**
  1609. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1610. * This function is deprecated. Use FromArrayToRef instead.
  1611. * @param array defines the source array
  1612. * @param offset defines the offset in the source array
  1613. * @param result defines the Vector3 where to store the result
  1614. */
  1615. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1616. /**
  1617. * Sets the given vector "result" with the given floats.
  1618. * @param x defines the x coordinate of the source
  1619. * @param y defines the y coordinate of the source
  1620. * @param z defines the z coordinate of the source
  1621. * @param result defines the Vector3 where to store the result
  1622. */
  1623. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1624. /**
  1625. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1626. * @returns a new empty Vector3
  1627. */
  1628. static Zero(): Vector3;
  1629. /**
  1630. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1631. * @returns a new unit Vector3
  1632. */
  1633. static One(): Vector3;
  1634. /**
  1635. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1636. * @returns a new up Vector3
  1637. */
  1638. static Up(): Vector3;
  1639. /**
  1640. * Gets a up Vector3 that must not be updated
  1641. */
  1642. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1645. * @returns a new down Vector3
  1646. */
  1647. static Down(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1650. * @returns a new forward Vector3
  1651. */
  1652. static Forward(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1655. * @returns a new forward Vector3
  1656. */
  1657. static Backward(): Vector3;
  1658. /**
  1659. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1660. * @returns a new right Vector3
  1661. */
  1662. static Right(): Vector3;
  1663. /**
  1664. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1665. * @returns a new left Vector3
  1666. */
  1667. static Left(): Vector3;
  1668. /**
  1669. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1670. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1671. * @param vector defines the Vector3 to transform
  1672. * @param transformation defines the transformation matrix
  1673. * @returns the transformed Vector3
  1674. */
  1675. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1676. /**
  1677. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1678. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1679. * @param vector defines the Vector3 to transform
  1680. * @param transformation defines the transformation matrix
  1681. * @param result defines the Vector3 where to store the result
  1682. */
  1683. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1684. /**
  1685. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1686. * This method computes tranformed coordinates only, not transformed direction vectors
  1687. * @param x define the x coordinate of the source vector
  1688. * @param y define the y coordinate of the source vector
  1689. * @param z define the z coordinate of the source vector
  1690. * @param transformation defines the transformation matrix
  1691. * @param result defines the Vector3 where to store the result
  1692. */
  1693. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1694. /**
  1695. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1696. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @returns the new Vector3
  1700. */
  1701. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1702. /**
  1703. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1704. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1705. * @param vector defines the Vector3 to transform
  1706. * @param transformation defines the transformation matrix
  1707. * @param result defines the Vector3 where to store the result
  1708. */
  1709. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1710. /**
  1711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1713. * @param x define the x coordinate of the source vector
  1714. * @param y define the y coordinate of the source vector
  1715. * @param z define the z coordinate of the source vector
  1716. * @param transformation defines the transformation matrix
  1717. * @param result defines the Vector3 where to store the result
  1718. */
  1719. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1720. /**
  1721. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1722. * @param value1 defines the first control point
  1723. * @param value2 defines the second control point
  1724. * @param value3 defines the third control point
  1725. * @param value4 defines the fourth control point
  1726. * @param amount defines the amount on the spline to use
  1727. * @returns the new Vector3
  1728. */
  1729. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1730. /**
  1731. * 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"
  1732. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1733. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1734. * @param value defines the current value
  1735. * @param min defines the lower range value
  1736. * @param max defines the upper range value
  1737. * @returns the new Vector3
  1738. */
  1739. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1740. /**
  1741. * 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"
  1742. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1743. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1744. * @param value defines the current value
  1745. * @param min defines the lower range value
  1746. * @param max defines the upper range value
  1747. * @param result defines the Vector3 where to store the result
  1748. */
  1749. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1750. /**
  1751. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1752. * @param value1 defines the first control point
  1753. * @param tangent1 defines the first tangent vector
  1754. * @param value2 defines the second control point
  1755. * @param tangent2 defines the second tangent vector
  1756. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1757. * @returns the new Vector3
  1758. */
  1759. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1760. /**
  1761. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1762. * @param start defines the start value
  1763. * @param end defines the end value
  1764. * @param amount max defines amount between both (between 0 and 1)
  1765. * @returns the new Vector3
  1766. */
  1767. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1768. /**
  1769. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1770. * @param start defines the start value
  1771. * @param end defines the end value
  1772. * @param amount max defines amount between both (between 0 and 1)
  1773. * @param result defines the Vector3 where to store the result
  1774. */
  1775. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1776. /**
  1777. * Returns the dot product (float) between the vectors "left" and "right"
  1778. * @param left defines the left operand
  1779. * @param right defines the right operand
  1780. * @returns the dot product
  1781. */
  1782. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1783. /**
  1784. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1785. * The cross product is then orthogonal to both "left" and "right"
  1786. * @param left defines the left operand
  1787. * @param right defines the right operand
  1788. * @returns the cross product
  1789. */
  1790. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the cross product of "left" and "right"
  1793. * The cross product is then orthogonal to both "left" and "right"
  1794. * @param left defines the left operand
  1795. * @param right defines the right operand
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1799. /**
  1800. * Returns a new Vector3 as the normalization of the given vector
  1801. * @param vector defines the Vector3 to normalize
  1802. * @returns the new Vector3
  1803. */
  1804. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1805. /**
  1806. * Sets the given vector "result" with the normalization of the given first vector
  1807. * @param vector defines the Vector3 to normalize
  1808. * @param result defines the Vector3 where to store the result
  1809. */
  1810. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1811. /**
  1812. * Project a Vector3 onto screen space
  1813. * @param vector defines the Vector3 to project
  1814. * @param world defines the world matrix to use
  1815. * @param transform defines the transform (view x projection) matrix to use
  1816. * @param viewport defines the screen viewport to use
  1817. * @returns the new Vector3
  1818. */
  1819. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1820. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1821. /**
  1822. * Unproject from screen space to object space
  1823. * @param source defines the screen space Vector3 to use
  1824. * @param viewportWidth defines the current width of the viewport
  1825. * @param viewportHeight defines the current height of the viewport
  1826. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1827. * @param transform defines the transform (view x projection) matrix to use
  1828. * @returns the new Vector3
  1829. */
  1830. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1831. /**
  1832. * Unproject from screen space to object space
  1833. * @param source defines the screen space Vector3 to use
  1834. * @param viewportWidth defines the current width of the viewport
  1835. * @param viewportHeight defines the current height of the viewport
  1836. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1837. * @param view defines the view matrix to use
  1838. * @param projection defines the projection matrix to use
  1839. * @returns the new Vector3
  1840. */
  1841. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1842. /**
  1843. * Unproject from screen space to object space
  1844. * @param source defines the screen space Vector3 to use
  1845. * @param viewportWidth defines the current width of the viewport
  1846. * @param viewportHeight defines the current height of the viewport
  1847. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1848. * @param view defines the view matrix to use
  1849. * @param projection defines the projection matrix to use
  1850. * @param result defines the Vector3 where to store the result
  1851. */
  1852. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1853. /**
  1854. * Unproject from screen space to object space
  1855. * @param sourceX defines the screen space x coordinate to use
  1856. * @param sourceY defines the screen space y coordinate to use
  1857. * @param sourceZ defines the screen space z coordinate to use
  1858. * @param viewportWidth defines the current width of the viewport
  1859. * @param viewportHeight defines the current height of the viewport
  1860. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1861. * @param view defines the view matrix to use
  1862. * @param projection defines the projection matrix to use
  1863. * @param result defines the Vector3 where to store the result
  1864. */
  1865. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1866. /**
  1867. * Gets the minimal coordinate values between two Vector3
  1868. * @param left defines the first operand
  1869. * @param right defines the second operand
  1870. * @returns the new Vector3
  1871. */
  1872. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1873. /**
  1874. * Gets the maximal coordinate values between two Vector3
  1875. * @param left defines the first operand
  1876. * @param right defines the second operand
  1877. * @returns the new Vector3
  1878. */
  1879. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1880. /**
  1881. * Returns the distance between the vectors "value1" and "value2"
  1882. * @param value1 defines the first operand
  1883. * @param value2 defines the second operand
  1884. * @returns the distance
  1885. */
  1886. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1887. /**
  1888. * Returns the squared distance between the vectors "value1" and "value2"
  1889. * @param value1 defines the first operand
  1890. * @param value2 defines the second operand
  1891. * @returns the squared distance
  1892. */
  1893. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1894. /**
  1895. * Returns a new Vector3 located at the center between "value1" and "value2"
  1896. * @param value1 defines the first operand
  1897. * @param value2 defines the second operand
  1898. * @returns the new Vector3
  1899. */
  1900. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1901. /**
  1902. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1903. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1904. * to something in order to rotate it from its local system to the given target system
  1905. * Note: axis1, axis2 and axis3 are normalized during this operation
  1906. * @param axis1 defines the first axis
  1907. * @param axis2 defines the second axis
  1908. * @param axis3 defines the third axis
  1909. * @returns a new Vector3
  1910. */
  1911. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1912. /**
  1913. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1914. * @param axis1 defines the first axis
  1915. * @param axis2 defines the second axis
  1916. * @param axis3 defines the third axis
  1917. * @param ref defines the Vector3 where to store the result
  1918. */
  1919. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1920. }
  1921. /**
  1922. * Vector4 class created for EulerAngle class conversion to Quaternion
  1923. */
  1924. export class Vector4 {
  1925. /** x value of the vector */
  1926. x: number;
  1927. /** y value of the vector */
  1928. y: number;
  1929. /** z value of the vector */
  1930. z: number;
  1931. /** w value of the vector */
  1932. w: number;
  1933. /**
  1934. * Creates a Vector4 object from the given floats.
  1935. * @param x x value of the vector
  1936. * @param y y value of the vector
  1937. * @param z z value of the vector
  1938. * @param w w value of the vector
  1939. */
  1940. constructor(
  1941. /** x value of the vector */
  1942. x: number,
  1943. /** y value of the vector */
  1944. y: number,
  1945. /** z value of the vector */
  1946. z: number,
  1947. /** w value of the vector */
  1948. w: number);
  1949. /**
  1950. * Returns the string with the Vector4 coordinates.
  1951. * @returns a string containing all the vector values
  1952. */
  1953. toString(): string;
  1954. /**
  1955. * Returns the string "Vector4".
  1956. * @returns "Vector4"
  1957. */
  1958. getClassName(): string;
  1959. /**
  1960. * Returns the Vector4 hash code.
  1961. * @returns a unique hash code
  1962. */
  1963. getHashCode(): number;
  1964. /**
  1965. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1966. * @returns the resulting array
  1967. */
  1968. asArray(): number[];
  1969. /**
  1970. * Populates the given array from the given index with the Vector4 coordinates.
  1971. * @param array array to populate
  1972. * @param index index of the array to start at (default: 0)
  1973. * @returns the Vector4.
  1974. */
  1975. toArray(array: FloatArray, index?: number): Vector4;
  1976. /**
  1977. * Adds the given vector to the current Vector4.
  1978. * @param otherVector the vector to add
  1979. * @returns the updated Vector4.
  1980. */
  1981. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1982. /**
  1983. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1984. * @param otherVector the vector to add
  1985. * @returns the resulting vector
  1986. */
  1987. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1988. /**
  1989. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1990. * @param otherVector the vector to add
  1991. * @param result the vector to store the result
  1992. * @returns the current Vector4.
  1993. */
  1994. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1995. /**
  1996. * Subtract in place the given vector from the current Vector4.
  1997. * @param otherVector the vector to subtract
  1998. * @returns the updated Vector4.
  1999. */
  2000. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2001. /**
  2002. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2003. * @param otherVector the vector to add
  2004. * @returns the new vector with the result
  2005. */
  2006. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2007. /**
  2008. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2009. * @param otherVector the vector to subtract
  2010. * @param result the vector to store the result
  2011. * @returns the current Vector4.
  2012. */
  2013. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2014. /**
  2015. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2016. */
  2017. /**
  2018. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2019. * @param x value to subtract
  2020. * @param y value to subtract
  2021. * @param z value to subtract
  2022. * @param w value to subtract
  2023. * @returns new vector containing the result
  2024. */
  2025. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2026. /**
  2027. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2028. * @param x value to subtract
  2029. * @param y value to subtract
  2030. * @param z value to subtract
  2031. * @param w value to subtract
  2032. * @param result the vector to store the result in
  2033. * @returns the current Vector4.
  2034. */
  2035. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2036. /**
  2037. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2038. * @returns a new vector with the negated values
  2039. */
  2040. negate(): Vector4;
  2041. /**
  2042. * Multiplies the current Vector4 coordinates by scale (float).
  2043. * @param scale the number to scale with
  2044. * @returns the updated Vector4.
  2045. */
  2046. scaleInPlace(scale: number): Vector4;
  2047. /**
  2048. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2049. * @param scale the number to scale with
  2050. * @returns a new vector with the result
  2051. */
  2052. scale(scale: number): Vector4;
  2053. /**
  2054. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2055. * @param scale the number to scale with
  2056. * @param result a vector to store the result in
  2057. * @returns the current Vector4.
  2058. */
  2059. scaleToRef(scale: number, result: Vector4): Vector4;
  2060. /**
  2061. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2062. * @param scale defines the scale factor
  2063. * @param result defines the Vector4 object where to store the result
  2064. * @returns the unmodified current Vector4
  2065. */
  2066. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2067. /**
  2068. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2069. * @param otherVector the vector to compare against
  2070. * @returns true if they are equal
  2071. */
  2072. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2073. /**
  2074. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2075. * @param otherVector vector to compare against
  2076. * @param epsilon (Default: very small number)
  2077. * @returns true if they are equal
  2078. */
  2079. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2080. /**
  2081. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2082. * @param x x value to compare against
  2083. * @param y y value to compare against
  2084. * @param z z value to compare against
  2085. * @param w w value to compare against
  2086. * @returns true if equal
  2087. */
  2088. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2089. /**
  2090. * Multiplies in place the current Vector4 by the given one.
  2091. * @param otherVector vector to multiple with
  2092. * @returns the updated Vector4.
  2093. */
  2094. multiplyInPlace(otherVector: Vector4): Vector4;
  2095. /**
  2096. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2097. * @param otherVector vector to multiple with
  2098. * @returns resulting new vector
  2099. */
  2100. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2101. /**
  2102. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2103. * @param otherVector vector to multiple with
  2104. * @param result vector to store the result
  2105. * @returns the current Vector4.
  2106. */
  2107. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2108. /**
  2109. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2110. * @param x x value multiply with
  2111. * @param y y value multiply with
  2112. * @param z z value multiply with
  2113. * @param w w value multiply with
  2114. * @returns resulting new vector
  2115. */
  2116. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2117. /**
  2118. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2119. * @param otherVector vector to devide with
  2120. * @returns resulting new vector
  2121. */
  2122. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2123. /**
  2124. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2125. * @param otherVector vector to devide with
  2126. * @param result vector to store the result
  2127. * @returns the current Vector4.
  2128. */
  2129. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2130. /**
  2131. * Divides the current Vector3 coordinates by the given ones.
  2132. * @param otherVector vector to devide with
  2133. * @returns the updated Vector3.
  2134. */
  2135. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2136. /**
  2137. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2138. * @param other defines the second operand
  2139. * @returns the current updated Vector4
  2140. */
  2141. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2142. /**
  2143. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2144. * @param other defines the second operand
  2145. * @returns the current updated Vector4
  2146. */
  2147. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2148. /**
  2149. * Gets a new Vector4 from current Vector4 floored values
  2150. * @returns a new Vector4
  2151. */
  2152. floor(): Vector4;
  2153. /**
  2154. * Gets a new Vector4 from current Vector3 floored values
  2155. * @returns a new Vector4
  2156. */
  2157. fract(): Vector4;
  2158. /**
  2159. * Returns the Vector4 length (float).
  2160. * @returns the length
  2161. */
  2162. length(): number;
  2163. /**
  2164. * Returns the Vector4 squared length (float).
  2165. * @returns the length squared
  2166. */
  2167. lengthSquared(): number;
  2168. /**
  2169. * Normalizes in place the Vector4.
  2170. * @returns the updated Vector4.
  2171. */
  2172. normalize(): Vector4;
  2173. /**
  2174. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2175. * @returns this converted to a new vector3
  2176. */
  2177. toVector3(): Vector3;
  2178. /**
  2179. * Returns a new Vector4 copied from the current one.
  2180. * @returns the new cloned vector
  2181. */
  2182. clone(): Vector4;
  2183. /**
  2184. * Updates the current Vector4 with the given one coordinates.
  2185. * @param source the source vector to copy from
  2186. * @returns the updated Vector4.
  2187. */
  2188. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2189. /**
  2190. * Updates the current Vector4 coordinates with the given floats.
  2191. * @param x float to copy from
  2192. * @param y float to copy from
  2193. * @param z float to copy from
  2194. * @param w float to copy from
  2195. * @returns the updated Vector4.
  2196. */
  2197. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2198. /**
  2199. * Updates the current Vector4 coordinates with the given floats.
  2200. * @param x float to set from
  2201. * @param y float to set from
  2202. * @param z float to set from
  2203. * @param w float to set from
  2204. * @returns the updated Vector4.
  2205. */
  2206. set(x: number, y: number, z: number, w: number): Vector4;
  2207. /**
  2208. * Copies the given float to the current Vector3 coordinates
  2209. * @param v defines the x, y, z and w coordinates of the operand
  2210. * @returns the current updated Vector3
  2211. */
  2212. setAll(v: number): Vector4;
  2213. /**
  2214. * Returns a new Vector4 set from the starting index of the given array.
  2215. * @param array the array to pull values from
  2216. * @param offset the offset into the array to start at
  2217. * @returns the new vector
  2218. */
  2219. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2220. /**
  2221. * Updates the given vector "result" from the starting index of the given array.
  2222. * @param array the array to pull values from
  2223. * @param offset the offset into the array to start at
  2224. * @param result the vector to store the result in
  2225. */
  2226. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2227. /**
  2228. * Updates the given vector "result" from the starting index of the given Float32Array.
  2229. * @param array the array to pull values from
  2230. * @param offset the offset into the array to start at
  2231. * @param result the vector to store the result in
  2232. */
  2233. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2234. /**
  2235. * Updates the given vector "result" coordinates from the given floats.
  2236. * @param x float to set from
  2237. * @param y float to set from
  2238. * @param z float to set from
  2239. * @param w float to set from
  2240. * @param result the vector to the floats in
  2241. */
  2242. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2243. /**
  2244. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2245. * @returns the new vector
  2246. */
  2247. static Zero(): Vector4;
  2248. /**
  2249. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2250. * @returns the new vector
  2251. */
  2252. static One(): Vector4;
  2253. /**
  2254. * Returns a new normalized Vector4 from the given one.
  2255. * @param vector the vector to normalize
  2256. * @returns the vector
  2257. */
  2258. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2259. /**
  2260. * Updates the given vector "result" from the normalization of the given one.
  2261. * @param vector the vector to normalize
  2262. * @param result the vector to store the result in
  2263. */
  2264. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2265. /**
  2266. * Returns a vector with the minimum values from the left and right vectors
  2267. * @param left left vector to minimize
  2268. * @param right right vector to minimize
  2269. * @returns a new vector with the minimum of the left and right vector values
  2270. */
  2271. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2272. /**
  2273. * Returns a vector with the maximum values from the left and right vectors
  2274. * @param left left vector to maximize
  2275. * @param right right vector to maximize
  2276. * @returns a new vector with the maximum of the left and right vector values
  2277. */
  2278. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2279. /**
  2280. * Returns the distance (float) between the vectors "value1" and "value2".
  2281. * @param value1 value to calulate the distance between
  2282. * @param value2 value to calulate the distance between
  2283. * @return the distance between the two vectors
  2284. */
  2285. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2286. /**
  2287. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2288. * @param value1 value to calulate the distance between
  2289. * @param value2 value to calulate the distance between
  2290. * @return the distance between the two vectors squared
  2291. */
  2292. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2293. /**
  2294. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2295. * @param value1 value to calulate the center between
  2296. * @param value2 value to calulate the center between
  2297. * @return the center between the two vectors
  2298. */
  2299. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2300. /**
  2301. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2302. * This methods computes transformed normalized direction vectors only.
  2303. * @param vector the vector to transform
  2304. * @param transformation the transformation matrix to apply
  2305. * @returns the new vector
  2306. */
  2307. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2308. /**
  2309. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2310. * This methods computes transformed normalized direction vectors only.
  2311. * @param vector the vector to transform
  2312. * @param transformation the transformation matrix to apply
  2313. * @param result the vector to store the result in
  2314. */
  2315. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2316. /**
  2317. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2318. * This methods computes transformed normalized direction vectors only.
  2319. * @param x value to transform
  2320. * @param y value to transform
  2321. * @param z value to transform
  2322. * @param w value to transform
  2323. * @param transformation the transformation matrix to apply
  2324. * @param result the vector to store the results in
  2325. */
  2326. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2327. /**
  2328. * Creates a new Vector4 from a Vector3
  2329. * @param source defines the source data
  2330. * @param w defines the 4th component (default is 0)
  2331. * @returns a new Vector4
  2332. */
  2333. static FromVector3(source: Vector3, w?: number): Vector4;
  2334. }
  2335. /**
  2336. * Interface for the size containing width and height
  2337. */
  2338. export interface ISize {
  2339. /**
  2340. * Width
  2341. */
  2342. width: number;
  2343. /**
  2344. * Heighht
  2345. */
  2346. height: number;
  2347. }
  2348. /**
  2349. * Size containing widht and height
  2350. */
  2351. export class Size implements ISize {
  2352. /**
  2353. * Width
  2354. */
  2355. width: number;
  2356. /**
  2357. * Height
  2358. */
  2359. height: number;
  2360. /**
  2361. * Creates a Size object from the given width and height (floats).
  2362. * @param width width of the new size
  2363. * @param height height of the new size
  2364. */
  2365. constructor(width: number, height: number);
  2366. /**
  2367. * Returns a string with the Size width and height
  2368. * @returns a string with the Size width and height
  2369. */
  2370. toString(): string;
  2371. /**
  2372. * "Size"
  2373. * @returns the string "Size"
  2374. */
  2375. getClassName(): string;
  2376. /**
  2377. * Returns the Size hash code.
  2378. * @returns a hash code for a unique width and height
  2379. */
  2380. getHashCode(): number;
  2381. /**
  2382. * Updates the current size from the given one.
  2383. * @param src the given size
  2384. */
  2385. copyFrom(src: Size): void;
  2386. /**
  2387. * Updates in place the current Size from the given floats.
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. * @returns the updated Size.
  2391. */
  2392. copyFromFloats(width: number, height: number): Size;
  2393. /**
  2394. * Updates in place the current Size from the given floats.
  2395. * @param width width to set
  2396. * @param height height to set
  2397. * @returns the updated Size.
  2398. */
  2399. set(width: number, height: number): Size;
  2400. /**
  2401. * Multiplies the width and height by numbers
  2402. * @param w factor to multiple the width by
  2403. * @param h factor to multiple the height by
  2404. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2405. */
  2406. multiplyByFloats(w: number, h: number): Size;
  2407. /**
  2408. * Clones the size
  2409. * @returns a new Size copied from the given one.
  2410. */
  2411. clone(): Size;
  2412. /**
  2413. * True if the current Size and the given one width and height are strictly equal.
  2414. * @param other the other size to compare against
  2415. * @returns True if the current Size and the given one width and height are strictly equal.
  2416. */
  2417. equals(other: Size): boolean;
  2418. /**
  2419. * The surface of the Size : width * height (float).
  2420. */
  2421. readonly surface: number;
  2422. /**
  2423. * Create a new size of zero
  2424. * @returns a new Size set to (0.0, 0.0)
  2425. */
  2426. static Zero(): Size;
  2427. /**
  2428. * Sums the width and height of two sizes
  2429. * @param otherSize size to add to this size
  2430. * @returns a new Size set as the addition result of the current Size and the given one.
  2431. */
  2432. add(otherSize: Size): Size;
  2433. /**
  2434. * Subtracts the width and height of two
  2435. * @param otherSize size to subtract to this size
  2436. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2437. */
  2438. subtract(otherSize: Size): Size;
  2439. /**
  2440. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2441. * @param start starting size to lerp between
  2442. * @param end end size to lerp between
  2443. * @param amount amount to lerp between the start and end values
  2444. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2445. */
  2446. static Lerp(start: Size, end: Size, amount: number): Size;
  2447. }
  2448. /**
  2449. * Class used to store quaternion data
  2450. * @see https://en.wikipedia.org/wiki/Quaternion
  2451. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2452. */
  2453. export class Quaternion {
  2454. /** defines the first component (0 by default) */
  2455. x: number;
  2456. /** defines the second component (0 by default) */
  2457. y: number;
  2458. /** defines the third component (0 by default) */
  2459. z: number;
  2460. /** defines the fourth component (1.0 by default) */
  2461. w: number;
  2462. /**
  2463. * Creates a new Quaternion from the given floats
  2464. * @param x defines the first component (0 by default)
  2465. * @param y defines the second component (0 by default)
  2466. * @param z defines the third component (0 by default)
  2467. * @param w defines the fourth component (1.0 by default)
  2468. */
  2469. constructor(
  2470. /** defines the first component (0 by default) */
  2471. x?: number,
  2472. /** defines the second component (0 by default) */
  2473. y?: number,
  2474. /** defines the third component (0 by default) */
  2475. z?: number,
  2476. /** defines the fourth component (1.0 by default) */
  2477. w?: number);
  2478. /**
  2479. * Gets a string representation for the current quaternion
  2480. * @returns a string with the Quaternion coordinates
  2481. */
  2482. toString(): string;
  2483. /**
  2484. * Gets the class name of the quaternion
  2485. * @returns the string "Quaternion"
  2486. */
  2487. getClassName(): string;
  2488. /**
  2489. * Gets a hash code for this quaternion
  2490. * @returns the quaternion hash code
  2491. */
  2492. getHashCode(): number;
  2493. /**
  2494. * Copy the quaternion to an array
  2495. * @returns a new array populated with 4 elements from the quaternion coordinates
  2496. */
  2497. asArray(): number[];
  2498. /**
  2499. * Check if two quaternions are equals
  2500. * @param otherQuaternion defines the second operand
  2501. * @return true if the current quaternion and the given one coordinates are strictly equals
  2502. */
  2503. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2504. /**
  2505. * Clone the current quaternion
  2506. * @returns a new quaternion copied from the current one
  2507. */
  2508. clone(): Quaternion;
  2509. /**
  2510. * Copy a quaternion to the current one
  2511. * @param other defines the other quaternion
  2512. * @returns the updated current quaternion
  2513. */
  2514. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2515. /**
  2516. * Updates the current quaternion with the given float coordinates
  2517. * @param x defines the x coordinate
  2518. * @param y defines the y coordinate
  2519. * @param z defines the z coordinate
  2520. * @param w defines the w coordinate
  2521. * @returns the updated current quaternion
  2522. */
  2523. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2524. /**
  2525. * Updates the current quaternion from the given float coordinates
  2526. * @param x defines the x coordinate
  2527. * @param y defines the y coordinate
  2528. * @param z defines the z coordinate
  2529. * @param w defines the w coordinate
  2530. * @returns the updated current quaternion
  2531. */
  2532. set(x: number, y: number, z: number, w: number): Quaternion;
  2533. /**
  2534. * Adds two quaternions
  2535. * @param other defines the second operand
  2536. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2537. */
  2538. add(other: DeepImmutable<Quaternion>): Quaternion;
  2539. /**
  2540. * Add a quaternion to the current one
  2541. * @param other defines the quaternion to add
  2542. * @returns the current quaternion
  2543. */
  2544. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2545. /**
  2546. * Subtract two quaternions
  2547. * @param other defines the second operand
  2548. * @returns a new quaternion as the subtraction result of the given one from the current one
  2549. */
  2550. subtract(other: Quaternion): Quaternion;
  2551. /**
  2552. * Multiplies the current quaternion by a scale factor
  2553. * @param value defines the scale factor
  2554. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2555. */
  2556. scale(value: number): Quaternion;
  2557. /**
  2558. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2559. * @param scale defines the scale factor
  2560. * @param result defines the Quaternion object where to store the result
  2561. * @returns the unmodified current quaternion
  2562. */
  2563. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2564. /**
  2565. * Multiplies in place the current quaternion by a scale factor
  2566. * @param value defines the scale factor
  2567. * @returns the current modified quaternion
  2568. */
  2569. scaleInPlace(value: number): Quaternion;
  2570. /**
  2571. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2572. * @param scale defines the scale factor
  2573. * @param result defines the Quaternion object where to store the result
  2574. * @returns the unmodified current quaternion
  2575. */
  2576. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies two quaternions
  2579. * @param q1 defines the second operand
  2580. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2581. */
  2582. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2583. /**
  2584. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2585. * @param q1 defines the second operand
  2586. * @param result defines the target quaternion
  2587. * @returns the current quaternion
  2588. */
  2589. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2590. /**
  2591. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2592. * @param q1 defines the second operand
  2593. * @returns the currentupdated quaternion
  2594. */
  2595. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2596. /**
  2597. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2598. * @param ref defines the target quaternion
  2599. * @returns the current quaternion
  2600. */
  2601. conjugateToRef(ref: Quaternion): Quaternion;
  2602. /**
  2603. * Conjugates in place (1-q) the current quaternion
  2604. * @returns the current updated quaternion
  2605. */
  2606. conjugateInPlace(): Quaternion;
  2607. /**
  2608. * Conjugates in place (1-q) the current quaternion
  2609. * @returns a new quaternion
  2610. */
  2611. conjugate(): Quaternion;
  2612. /**
  2613. * Gets length of current quaternion
  2614. * @returns the quaternion length (float)
  2615. */
  2616. length(): number;
  2617. /**
  2618. * Normalize in place the current quaternion
  2619. * @returns the current updated quaternion
  2620. */
  2621. normalize(): Quaternion;
  2622. /**
  2623. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2624. * @param order is a reserved parameter and is ignore for now
  2625. * @returns a new Vector3 containing the Euler angles
  2626. */
  2627. toEulerAngles(order?: string): Vector3;
  2628. /**
  2629. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2630. * @param result defines the vector which will be filled with the Euler angles
  2631. * @param order is a reserved parameter and is ignore for now
  2632. * @returns the current unchanged quaternion
  2633. */
  2634. toEulerAnglesToRef(result: Vector3): Quaternion;
  2635. /**
  2636. * Updates the given rotation matrix with the current quaternion values
  2637. * @param result defines the target matrix
  2638. * @returns the current unchanged quaternion
  2639. */
  2640. toRotationMatrix(result: Matrix): Quaternion;
  2641. /**
  2642. * Updates the current quaternion from the given rotation matrix values
  2643. * @param matrix defines the source matrix
  2644. * @returns the current updated quaternion
  2645. */
  2646. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2647. /**
  2648. * Creates a new quaternion from a rotation matrix
  2649. * @param matrix defines the source matrix
  2650. * @returns a new quaternion created from the given rotation matrix values
  2651. */
  2652. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2653. /**
  2654. * Updates the given quaternion with the given rotation matrix values
  2655. * @param matrix defines the source matrix
  2656. * @param result defines the target quaternion
  2657. */
  2658. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2659. /**
  2660. * Returns the dot product (float) between the quaternions "left" and "right"
  2661. * @param left defines the left operand
  2662. * @param right defines the right operand
  2663. * @returns the dot product
  2664. */
  2665. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2666. /**
  2667. * Checks if the two quaternions are close to each other
  2668. * @param quat0 defines the first quaternion to check
  2669. * @param quat1 defines the second quaternion to check
  2670. * @returns true if the two quaternions are close to each other
  2671. */
  2672. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2673. /**
  2674. * Creates an empty quaternion
  2675. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2676. */
  2677. static Zero(): Quaternion;
  2678. /**
  2679. * Inverse a given quaternion
  2680. * @param q defines the source quaternion
  2681. * @returns a new quaternion as the inverted current quaternion
  2682. */
  2683. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2684. /**
  2685. * Inverse a given quaternion
  2686. * @param q defines the source quaternion
  2687. * @param result the quaternion the result will be stored in
  2688. * @returns the result quaternion
  2689. */
  2690. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2691. /**
  2692. * Creates an identity quaternion
  2693. * @returns the identity quaternion
  2694. */
  2695. static Identity(): Quaternion;
  2696. /**
  2697. * Gets a boolean indicating if the given quaternion is identity
  2698. * @param quaternion defines the quaternion to check
  2699. * @returns true if the quaternion is identity
  2700. */
  2701. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2702. /**
  2703. * Creates a quaternion from a rotation around an axis
  2704. * @param axis defines the axis to use
  2705. * @param angle defines the angle to use
  2706. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2707. */
  2708. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2709. /**
  2710. * Creates a rotation around an axis and stores it into the given quaternion
  2711. * @param axis defines the axis to use
  2712. * @param angle defines the angle to use
  2713. * @param result defines the target quaternion
  2714. * @returns the target quaternion
  2715. */
  2716. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates a new quaternion from data stored into an array
  2719. * @param array defines the data source
  2720. * @param offset defines the offset in the source array where the data starts
  2721. * @returns a new quaternion
  2722. */
  2723. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2724. /**
  2725. * Create a quaternion from Euler rotation angles
  2726. * @param x Pitch
  2727. * @param y Yaw
  2728. * @param z Roll
  2729. * @returns the new Quaternion
  2730. */
  2731. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2732. /**
  2733. * Updates a quaternion from Euler rotation angles
  2734. * @param x Pitch
  2735. * @param y Yaw
  2736. * @param z Roll
  2737. * @param result the quaternion to store the result
  2738. * @returns the updated quaternion
  2739. */
  2740. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2741. /**
  2742. * Create a quaternion from Euler rotation vector
  2743. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2744. * @returns the new Quaternion
  2745. */
  2746. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2747. /**
  2748. * Updates a quaternion from Euler rotation vector
  2749. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2750. * @param result the quaternion to store the result
  2751. * @returns the updated quaternion
  2752. */
  2753. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2754. /**
  2755. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2756. * @param yaw defines the rotation around Y axis
  2757. * @param pitch defines the rotation around X axis
  2758. * @param roll defines the rotation around Z axis
  2759. * @returns the new quaternion
  2760. */
  2761. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2762. /**
  2763. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2764. * @param yaw defines the rotation around Y axis
  2765. * @param pitch defines the rotation around X axis
  2766. * @param roll defines the rotation around Z axis
  2767. * @param result defines the target quaternion
  2768. */
  2769. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2770. /**
  2771. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2772. * @param alpha defines the rotation around first axis
  2773. * @param beta defines the rotation around second axis
  2774. * @param gamma defines the rotation around third axis
  2775. * @returns the new quaternion
  2776. */
  2777. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2778. /**
  2779. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2780. * @param alpha defines the rotation around first axis
  2781. * @param beta defines the rotation around second axis
  2782. * @param gamma defines the rotation around third axis
  2783. * @param result defines the target quaternion
  2784. */
  2785. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2786. /**
  2787. * 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)
  2788. * @param axis1 defines the first axis
  2789. * @param axis2 defines the second axis
  2790. * @param axis3 defines the third axis
  2791. * @returns the new quaternion
  2792. */
  2793. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2794. /**
  2795. * 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
  2796. * @param axis1 defines the first axis
  2797. * @param axis2 defines the second axis
  2798. * @param axis3 defines the third axis
  2799. * @param ref defines the target quaternion
  2800. */
  2801. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2802. /**
  2803. * Interpolates between two quaternions
  2804. * @param left defines first quaternion
  2805. * @param right defines second quaternion
  2806. * @param amount defines the gradient to use
  2807. * @returns the new interpolated quaternion
  2808. */
  2809. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2810. /**
  2811. * Interpolates between two quaternions and stores it into a target quaternion
  2812. * @param left defines first quaternion
  2813. * @param right defines second quaternion
  2814. * @param amount defines the gradient to use
  2815. * @param result defines the target quaternion
  2816. */
  2817. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2818. /**
  2819. * Interpolate between two quaternions using Hermite interpolation
  2820. * @param value1 defines first quaternion
  2821. * @param tangent1 defines the incoming tangent
  2822. * @param value2 defines second quaternion
  2823. * @param tangent2 defines the outgoing tangent
  2824. * @param amount defines the target quaternion
  2825. * @returns the new interpolated quaternion
  2826. */
  2827. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2828. }
  2829. /**
  2830. * Class used to store matrix data (4x4)
  2831. */
  2832. export class Matrix {
  2833. private static _updateFlagSeed;
  2834. private static _identityReadOnly;
  2835. private _isIdentity;
  2836. private _isIdentityDirty;
  2837. private _isIdentity3x2;
  2838. private _isIdentity3x2Dirty;
  2839. /**
  2840. * Gets the update flag of the matrix which is an unique number for the matrix.
  2841. * It will be incremented every time the matrix data change.
  2842. * You can use it to speed the comparison between two versions of the same matrix.
  2843. */
  2844. updateFlag: number;
  2845. private readonly _m;
  2846. /**
  2847. * Gets the internal data of the matrix
  2848. */
  2849. readonly m: DeepImmutable<Float32Array>;
  2850. /** @hidden */ markAsUpdated(): void;
  2851. /** @hidden */
  2852. private _updateIdentityStatus;
  2853. /**
  2854. * Creates an empty matrix (filled with zeros)
  2855. */
  2856. constructor();
  2857. /**
  2858. * Check if the current matrix is identity
  2859. * @returns true is the matrix is the identity matrix
  2860. */
  2861. isIdentity(): boolean;
  2862. /**
  2863. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2864. * @returns true is the matrix is the identity matrix
  2865. */
  2866. isIdentityAs3x2(): boolean;
  2867. /**
  2868. * Gets the determinant of the matrix
  2869. * @returns the matrix determinant
  2870. */
  2871. determinant(): number;
  2872. /**
  2873. * Returns the matrix as a Float32Array
  2874. * @returns the matrix underlying array
  2875. */
  2876. toArray(): DeepImmutable<Float32Array>;
  2877. /**
  2878. * Returns the matrix as a Float32Array
  2879. * @returns the matrix underlying array.
  2880. */
  2881. asArray(): DeepImmutable<Float32Array>;
  2882. /**
  2883. * Inverts the current matrix in place
  2884. * @returns the current inverted matrix
  2885. */
  2886. invert(): Matrix;
  2887. /**
  2888. * Sets all the matrix elements to zero
  2889. * @returns the current matrix
  2890. */
  2891. reset(): Matrix;
  2892. /**
  2893. * Adds the current matrix with a second one
  2894. * @param other defines the matrix to add
  2895. * @returns a new matrix as the addition of the current matrix and the given one
  2896. */
  2897. add(other: DeepImmutable<Matrix>): Matrix;
  2898. /**
  2899. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2900. * @param other defines the matrix to add
  2901. * @param result defines the target matrix
  2902. * @returns the current matrix
  2903. */
  2904. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2905. /**
  2906. * Adds in place the given matrix to the current matrix
  2907. * @param other defines the second operand
  2908. * @returns the current updated matrix
  2909. */
  2910. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2911. /**
  2912. * Sets the given matrix to the current inverted Matrix
  2913. * @param other defines the target matrix
  2914. * @returns the unmodified current matrix
  2915. */
  2916. invertToRef(other: Matrix): Matrix;
  2917. /**
  2918. * add a value at the specified position in the current Matrix
  2919. * @param index the index of the value within the matrix. between 0 and 15.
  2920. * @param value the value to be added
  2921. * @returns the current updated matrix
  2922. */
  2923. addAtIndex(index: number, value: number): Matrix;
  2924. /**
  2925. * mutiply the specified position in the current Matrix by a value
  2926. * @param index the index of the value within the matrix. between 0 and 15.
  2927. * @param value the value to be added
  2928. * @returns the current updated matrix
  2929. */
  2930. multiplyAtIndex(index: number, value: number): Matrix;
  2931. /**
  2932. * Inserts the translation vector (using 3 floats) in the current matrix
  2933. * @param x defines the 1st component of the translation
  2934. * @param y defines the 2nd component of the translation
  2935. * @param z defines the 3rd component of the translation
  2936. * @returns the current updated matrix
  2937. */
  2938. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2939. /**
  2940. * Inserts the translation vector in the current matrix
  2941. * @param vector3 defines the translation to insert
  2942. * @returns the current updated matrix
  2943. */
  2944. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2945. /**
  2946. * Gets the translation value of the current matrix
  2947. * @returns a new Vector3 as the extracted translation from the matrix
  2948. */
  2949. getTranslation(): Vector3;
  2950. /**
  2951. * Fill a Vector3 with the extracted translation from the matrix
  2952. * @param result defines the Vector3 where to store the translation
  2953. * @returns the current matrix
  2954. */
  2955. getTranslationToRef(result: Vector3): Matrix;
  2956. /**
  2957. * Remove rotation and scaling part from the matrix
  2958. * @returns the updated matrix
  2959. */
  2960. removeRotationAndScaling(): Matrix;
  2961. /**
  2962. * Multiply two matrices
  2963. * @param other defines the second operand
  2964. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2965. */
  2966. multiply(other: DeepImmutable<Matrix>): Matrix;
  2967. /**
  2968. * Copy the current matrix from the given one
  2969. * @param other defines the source matrix
  2970. * @returns the current updated matrix
  2971. */
  2972. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2973. /**
  2974. * Populates the given array from the starting index with the current matrix values
  2975. * @param array defines the target array
  2976. * @param offset defines the offset in the target array where to start storing values
  2977. * @returns the current matrix
  2978. */
  2979. copyToArray(array: Float32Array, offset?: number): Matrix;
  2980. /**
  2981. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2982. * @param other defines the second operand
  2983. * @param result defines the matrix where to store the multiplication
  2984. * @returns the current matrix
  2985. */
  2986. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2987. /**
  2988. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2989. * @param other defines the second operand
  2990. * @param result defines the array where to store the multiplication
  2991. * @param offset defines the offset in the target array where to start storing values
  2992. * @returns the current matrix
  2993. */
  2994. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2995. /**
  2996. * Check equality between this matrix and a second one
  2997. * @param value defines the second matrix to compare
  2998. * @returns true is the current matrix and the given one values are strictly equal
  2999. */
  3000. equals(value: DeepImmutable<Matrix>): boolean;
  3001. /**
  3002. * Clone the current matrix
  3003. * @returns a new matrix from the current matrix
  3004. */
  3005. clone(): Matrix;
  3006. /**
  3007. * Returns the name of the current matrix class
  3008. * @returns the string "Matrix"
  3009. */
  3010. getClassName(): string;
  3011. /**
  3012. * Gets the hash code of the current matrix
  3013. * @returns the hash code
  3014. */
  3015. getHashCode(): number;
  3016. /**
  3017. * Decomposes the current Matrix into a translation, rotation and scaling components
  3018. * @param scale defines the scale vector3 given as a reference to update
  3019. * @param rotation defines the rotation quaternion given as a reference to update
  3020. * @param translation defines the translation vector3 given as a reference to update
  3021. * @returns true if operation was successful
  3022. */
  3023. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3024. /**
  3025. * Gets specific row of the matrix
  3026. * @param index defines the number of the row to get
  3027. * @returns the index-th row of the current matrix as a new Vector4
  3028. */
  3029. getRow(index: number): Nullable<Vector4>;
  3030. /**
  3031. * Sets the index-th row of the current matrix to the vector4 values
  3032. * @param index defines the number of the row to set
  3033. * @param row defines the target vector4
  3034. * @returns the updated current matrix
  3035. */
  3036. setRow(index: number, row: Vector4): Matrix;
  3037. /**
  3038. * Compute the transpose of the matrix
  3039. * @returns the new transposed matrix
  3040. */
  3041. transpose(): Matrix;
  3042. /**
  3043. * Compute the transpose of the matrix and store it in a given matrix
  3044. * @param result defines the target matrix
  3045. * @returns the current matrix
  3046. */
  3047. transposeToRef(result: Matrix): Matrix;
  3048. /**
  3049. * Sets the index-th row of the current matrix with the given 4 x float values
  3050. * @param index defines the row index
  3051. * @param x defines the x component to set
  3052. * @param y defines the y component to set
  3053. * @param z defines the z component to set
  3054. * @param w defines the w component to set
  3055. * @returns the updated current matrix
  3056. */
  3057. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3058. /**
  3059. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3060. * @param scale defines the scale factor
  3061. * @returns a new matrix
  3062. */
  3063. scale(scale: number): Matrix;
  3064. /**
  3065. * Scale the current matrix values by a factor to a given result matrix
  3066. * @param scale defines the scale factor
  3067. * @param result defines the matrix to store the result
  3068. * @returns the current matrix
  3069. */
  3070. scaleToRef(scale: number, result: Matrix): Matrix;
  3071. /**
  3072. * Scale the current matrix values by a factor and add the result to a given matrix
  3073. * @param scale defines the scale factor
  3074. * @param result defines the Matrix to store the result
  3075. * @returns the current matrix
  3076. */
  3077. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3078. /**
  3079. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3080. * @param ref matrix to store the result
  3081. */
  3082. toNormalMatrix(ref: Matrix): void;
  3083. /**
  3084. * Gets only rotation part of the current matrix
  3085. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3086. */
  3087. getRotationMatrix(): Matrix;
  3088. /**
  3089. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3090. * @param result defines the target matrix to store data to
  3091. * @returns the current matrix
  3092. */
  3093. getRotationMatrixToRef(result: Matrix): Matrix;
  3094. /**
  3095. * Toggles model matrix from being right handed to left handed in place and vice versa
  3096. */
  3097. toggleModelMatrixHandInPlace(): void;
  3098. /**
  3099. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3100. */
  3101. toggleProjectionMatrixHandInPlace(): void;
  3102. /**
  3103. * Creates a matrix from an array
  3104. * @param array defines the source array
  3105. * @param offset defines an offset in the source array
  3106. * @returns a new Matrix set from the starting index of the given array
  3107. */
  3108. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3109. /**
  3110. * Copy the content of an array into a given matrix
  3111. * @param array defines the source array
  3112. * @param offset defines an offset in the source array
  3113. * @param result defines the target matrix
  3114. */
  3115. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3116. /**
  3117. * Stores an array into a matrix after having multiplied each component by a given factor
  3118. * @param array defines the source array
  3119. * @param offset defines the offset in the source array
  3120. * @param scale defines the scaling factor
  3121. * @param result defines the target matrix
  3122. */
  3123. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3124. /**
  3125. * Gets an identity matrix that must not be updated
  3126. */
  3127. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3128. /**
  3129. * Stores a list of values (16) inside a given matrix
  3130. * @param initialM11 defines 1st value of 1st row
  3131. * @param initialM12 defines 2nd value of 1st row
  3132. * @param initialM13 defines 3rd value of 1st row
  3133. * @param initialM14 defines 4th value of 1st row
  3134. * @param initialM21 defines 1st value of 2nd row
  3135. * @param initialM22 defines 2nd value of 2nd row
  3136. * @param initialM23 defines 3rd value of 2nd row
  3137. * @param initialM24 defines 4th value of 2nd row
  3138. * @param initialM31 defines 1st value of 3rd row
  3139. * @param initialM32 defines 2nd value of 3rd row
  3140. * @param initialM33 defines 3rd value of 3rd row
  3141. * @param initialM34 defines 4th value of 3rd row
  3142. * @param initialM41 defines 1st value of 4th row
  3143. * @param initialM42 defines 2nd value of 4th row
  3144. * @param initialM43 defines 3rd value of 4th row
  3145. * @param initialM44 defines 4th value of 4th row
  3146. * @param result defines the target matrix
  3147. */
  3148. 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;
  3149. /**
  3150. * Creates new matrix from a list of values (16)
  3151. * @param initialM11 defines 1st value of 1st row
  3152. * @param initialM12 defines 2nd value of 1st row
  3153. * @param initialM13 defines 3rd value of 1st row
  3154. * @param initialM14 defines 4th value of 1st row
  3155. * @param initialM21 defines 1st value of 2nd row
  3156. * @param initialM22 defines 2nd value of 2nd row
  3157. * @param initialM23 defines 3rd value of 2nd row
  3158. * @param initialM24 defines 4th value of 2nd row
  3159. * @param initialM31 defines 1st value of 3rd row
  3160. * @param initialM32 defines 2nd value of 3rd row
  3161. * @param initialM33 defines 3rd value of 3rd row
  3162. * @param initialM34 defines 4th value of 3rd row
  3163. * @param initialM41 defines 1st value of 4th row
  3164. * @param initialM42 defines 2nd value of 4th row
  3165. * @param initialM43 defines 3rd value of 4th row
  3166. * @param initialM44 defines 4th value of 4th row
  3167. * @returns the new matrix
  3168. */
  3169. 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;
  3170. /**
  3171. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3172. * @param scale defines the scale vector3
  3173. * @param rotation defines the rotation quaternion
  3174. * @param translation defines the translation vector3
  3175. * @returns a new matrix
  3176. */
  3177. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3178. /**
  3179. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3180. * @param scale defines the scale vector3
  3181. * @param rotation defines the rotation quaternion
  3182. * @param translation defines the translation vector3
  3183. * @param result defines the target matrix
  3184. */
  3185. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3186. /**
  3187. * Creates a new identity matrix
  3188. * @returns a new identity matrix
  3189. */
  3190. static Identity(): Matrix;
  3191. /**
  3192. * Creates a new identity matrix and stores the result in a given matrix
  3193. * @param result defines the target matrix
  3194. */
  3195. static IdentityToRef(result: Matrix): void;
  3196. /**
  3197. * Creates a new zero matrix
  3198. * @returns a new zero matrix
  3199. */
  3200. static Zero(): Matrix;
  3201. /**
  3202. * Creates a new rotation matrix for "angle" radians around the X axis
  3203. * @param angle defines the angle (in radians) to use
  3204. * @return the new matrix
  3205. */
  3206. static RotationX(angle: number): Matrix;
  3207. /**
  3208. * Creates a new matrix as the invert of a given matrix
  3209. * @param source defines the source matrix
  3210. * @returns the new matrix
  3211. */
  3212. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3213. /**
  3214. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3215. * @param angle defines the angle (in radians) to use
  3216. * @param result defines the target matrix
  3217. */
  3218. static RotationXToRef(angle: number, result: Matrix): void;
  3219. /**
  3220. * Creates a new rotation matrix for "angle" radians around the Y axis
  3221. * @param angle defines the angle (in radians) to use
  3222. * @return the new matrix
  3223. */
  3224. static RotationY(angle: number): Matrix;
  3225. /**
  3226. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3227. * @param angle defines the angle (in radians) to use
  3228. * @param result defines the target matrix
  3229. */
  3230. static RotationYToRef(angle: number, result: Matrix): void;
  3231. /**
  3232. * Creates a new rotation matrix for "angle" radians around the Z axis
  3233. * @param angle defines the angle (in radians) to use
  3234. * @return the new matrix
  3235. */
  3236. static RotationZ(angle: number): Matrix;
  3237. /**
  3238. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3239. * @param angle defines the angle (in radians) to use
  3240. * @param result defines the target matrix
  3241. */
  3242. static RotationZToRef(angle: number, result: Matrix): void;
  3243. /**
  3244. * Creates a new rotation matrix for "angle" radians around the given axis
  3245. * @param axis defines the axis to use
  3246. * @param angle defines the angle (in radians) to use
  3247. * @return the new matrix
  3248. */
  3249. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3250. /**
  3251. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3252. * @param axis defines the axis to use
  3253. * @param angle defines the angle (in radians) to use
  3254. * @param result defines the target matrix
  3255. */
  3256. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3257. /**
  3258. * Creates a rotation matrix
  3259. * @param yaw defines the yaw angle in radians (Y axis)
  3260. * @param pitch defines the pitch angle in radians (X axis)
  3261. * @param roll defines the roll angle in radians (X axis)
  3262. * @returns the new rotation matrix
  3263. */
  3264. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3265. /**
  3266. * Creates a rotation matrix and stores it in a given matrix
  3267. * @param yaw defines the yaw angle in radians (Y axis)
  3268. * @param pitch defines the pitch angle in radians (X axis)
  3269. * @param roll defines the roll angle in radians (X axis)
  3270. * @param result defines the target matrix
  3271. */
  3272. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3273. /**
  3274. * Creates a scaling matrix
  3275. * @param x defines the scale factor on X axis
  3276. * @param y defines the scale factor on Y axis
  3277. * @param z defines the scale factor on Z axis
  3278. * @returns the new matrix
  3279. */
  3280. static Scaling(x: number, y: number, z: number): Matrix;
  3281. /**
  3282. * Creates a scaling matrix and stores it in a given matrix
  3283. * @param x defines the scale factor on X axis
  3284. * @param y defines the scale factor on Y axis
  3285. * @param z defines the scale factor on Z axis
  3286. * @param result defines the target matrix
  3287. */
  3288. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3289. /**
  3290. * Creates a translation matrix
  3291. * @param x defines the translation on X axis
  3292. * @param y defines the translation on Y axis
  3293. * @param z defines the translationon Z axis
  3294. * @returns the new matrix
  3295. */
  3296. static Translation(x: number, y: number, z: number): Matrix;
  3297. /**
  3298. * Creates a translation matrix and stores it in a given matrix
  3299. * @param x defines the translation on X axis
  3300. * @param y defines the translation on Y axis
  3301. * @param z defines the translationon Z axis
  3302. * @param result defines the target matrix
  3303. */
  3304. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3305. /**
  3306. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3307. * @param startValue defines the start value
  3308. * @param endValue defines the end value
  3309. * @param gradient defines the gradient factor
  3310. * @returns the new matrix
  3311. */
  3312. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3313. /**
  3314. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3315. * @param startValue defines the start value
  3316. * @param endValue defines the end value
  3317. * @param gradient defines the gradient factor
  3318. * @param result defines the Matrix object where to store data
  3319. */
  3320. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3321. /**
  3322. * Builds a new matrix whose values are computed by:
  3323. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3324. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3325. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3326. * @param startValue defines the first matrix
  3327. * @param endValue defines the second matrix
  3328. * @param gradient defines the gradient between the two matrices
  3329. * @returns the new matrix
  3330. */
  3331. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3332. /**
  3333. * Update a matrix to values which are computed by:
  3334. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3335. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3336. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3337. * @param startValue defines the first matrix
  3338. * @param endValue defines the second matrix
  3339. * @param gradient defines the gradient between the two matrices
  3340. * @param result defines the target matrix
  3341. */
  3342. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3343. /**
  3344. * 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"
  3345. * This function works in left handed mode
  3346. * @param eye defines the final position of the entity
  3347. * @param target defines where the entity should look at
  3348. * @param up defines the up vector for the entity
  3349. * @returns the new matrix
  3350. */
  3351. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3352. /**
  3353. * 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".
  3354. * This function works in left handed mode
  3355. * @param eye defines the final position of the entity
  3356. * @param target defines where the entity should look at
  3357. * @param up defines the up vector for the entity
  3358. * @param result defines the target matrix
  3359. */
  3360. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3361. /**
  3362. * 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"
  3363. * This function works in right handed mode
  3364. * @param eye defines the final position of the entity
  3365. * @param target defines where the entity should look at
  3366. * @param up defines the up vector for the entity
  3367. * @returns the new matrix
  3368. */
  3369. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3370. /**
  3371. * 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".
  3372. * This function works in right handed mode
  3373. * @param eye defines the final position of the entity
  3374. * @param target defines where the entity should look at
  3375. * @param up defines the up vector for the entity
  3376. * @param result defines the target matrix
  3377. */
  3378. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3379. /**
  3380. * Create a left-handed orthographic projection matrix
  3381. * @param width defines the viewport width
  3382. * @param height defines the viewport height
  3383. * @param znear defines the near clip plane
  3384. * @param zfar defines the far clip plane
  3385. * @returns a new matrix as a left-handed orthographic projection matrix
  3386. */
  3387. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3388. /**
  3389. * Store a left-handed orthographic projection to a given matrix
  3390. * @param width defines the viewport width
  3391. * @param height defines the viewport height
  3392. * @param znear defines the near clip plane
  3393. * @param zfar defines the far clip plane
  3394. * @param result defines the target matrix
  3395. */
  3396. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3397. /**
  3398. * Create a left-handed orthographic projection matrix
  3399. * @param left defines the viewport left coordinate
  3400. * @param right defines the viewport right coordinate
  3401. * @param bottom defines the viewport bottom coordinate
  3402. * @param top defines the viewport top coordinate
  3403. * @param znear defines the near clip plane
  3404. * @param zfar defines the far clip plane
  3405. * @returns a new matrix as a left-handed orthographic projection matrix
  3406. */
  3407. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3408. /**
  3409. * Stores a left-handed orthographic projection into a given matrix
  3410. * @param left defines the viewport left coordinate
  3411. * @param right defines the viewport right coordinate
  3412. * @param bottom defines the viewport bottom coordinate
  3413. * @param top defines the viewport top coordinate
  3414. * @param znear defines the near clip plane
  3415. * @param zfar defines the far clip plane
  3416. * @param result defines the target matrix
  3417. */
  3418. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3419. /**
  3420. * Creates a right-handed orthographic projection matrix
  3421. * @param left defines the viewport left coordinate
  3422. * @param right defines the viewport right coordinate
  3423. * @param bottom defines the viewport bottom coordinate
  3424. * @param top defines the viewport top coordinate
  3425. * @param znear defines the near clip plane
  3426. * @param zfar defines the far clip plane
  3427. * @returns a new matrix as a right-handed orthographic projection matrix
  3428. */
  3429. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3430. /**
  3431. * Stores a right-handed orthographic projection into a given matrix
  3432. * @param left defines the viewport left coordinate
  3433. * @param right defines the viewport right coordinate
  3434. * @param bottom defines the viewport bottom coordinate
  3435. * @param top defines the viewport top coordinate
  3436. * @param znear defines the near clip plane
  3437. * @param zfar defines the far clip plane
  3438. * @param result defines the target matrix
  3439. */
  3440. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3441. /**
  3442. * Creates a left-handed perspective projection matrix
  3443. * @param width defines the viewport width
  3444. * @param height defines the viewport height
  3445. * @param znear defines the near clip plane
  3446. * @param zfar defines the far clip plane
  3447. * @returns a new matrix as a left-handed perspective projection matrix
  3448. */
  3449. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3450. /**
  3451. * Creates a left-handed perspective projection matrix
  3452. * @param fov defines the horizontal field of view
  3453. * @param aspect defines the aspect ratio
  3454. * @param znear defines the near clip plane
  3455. * @param zfar defines the far clip plane
  3456. * @returns a new matrix as a left-handed perspective projection matrix
  3457. */
  3458. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3459. /**
  3460. * Stores a left-handed perspective projection into a given matrix
  3461. * @param fov defines the horizontal field of view
  3462. * @param aspect defines the aspect ratio
  3463. * @param znear defines the near clip plane
  3464. * @param zfar defines the far clip plane
  3465. * @param result defines the target matrix
  3466. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3467. */
  3468. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3469. /**
  3470. * Creates a right-handed perspective projection matrix
  3471. * @param fov defines the horizontal field of view
  3472. * @param aspect defines the aspect ratio
  3473. * @param znear defines the near clip plane
  3474. * @param zfar defines the far clip plane
  3475. * @returns a new matrix as a right-handed perspective projection matrix
  3476. */
  3477. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3478. /**
  3479. * Stores a right-handed perspective projection into a given matrix
  3480. * @param fov defines the horizontal field of view
  3481. * @param aspect defines the aspect ratio
  3482. * @param znear defines the near clip plane
  3483. * @param zfar defines the far clip plane
  3484. * @param result defines the target matrix
  3485. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3486. */
  3487. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3488. /**
  3489. * Stores a perspective projection for WebVR info a given matrix
  3490. * @param fov defines the field of view
  3491. * @param znear defines the near clip plane
  3492. * @param zfar defines the far clip plane
  3493. * @param result defines the target matrix
  3494. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3495. */
  3496. static PerspectiveFovWebVRToRef(fov: {
  3497. upDegrees: number;
  3498. downDegrees: number;
  3499. leftDegrees: number;
  3500. rightDegrees: number;
  3501. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3502. /**
  3503. * Computes a complete transformation matrix
  3504. * @param viewport defines the viewport to use
  3505. * @param world defines the world matrix
  3506. * @param view defines the view matrix
  3507. * @param projection defines the projection matrix
  3508. * @param zmin defines the near clip plane
  3509. * @param zmax defines the far clip plane
  3510. * @returns the transformation matrix
  3511. */
  3512. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3513. /**
  3514. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3515. * @param matrix defines the matrix to use
  3516. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3517. */
  3518. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3519. /**
  3520. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3521. * @param matrix defines the matrix to use
  3522. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3523. */
  3524. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3525. /**
  3526. * Compute the transpose of a given matrix
  3527. * @param matrix defines the matrix to transpose
  3528. * @returns the new matrix
  3529. */
  3530. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3531. /**
  3532. * Compute the transpose of a matrix and store it in a target matrix
  3533. * @param matrix defines the matrix to transpose
  3534. * @param result defines the target matrix
  3535. */
  3536. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3537. /**
  3538. * Computes a reflection matrix from a plane
  3539. * @param plane defines the reflection plane
  3540. * @returns a new matrix
  3541. */
  3542. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3543. /**
  3544. * Computes a reflection matrix from a plane
  3545. * @param plane defines the reflection plane
  3546. * @param result defines the target matrix
  3547. */
  3548. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3549. /**
  3550. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3551. * @param xaxis defines the value of the 1st axis
  3552. * @param yaxis defines the value of the 2nd axis
  3553. * @param zaxis defines the value of the 3rd axis
  3554. * @param result defines the target matrix
  3555. */
  3556. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3557. /**
  3558. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3559. * @param quat defines the quaternion to use
  3560. * @param result defines the target matrix
  3561. */
  3562. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3563. }
  3564. /**
  3565. * Represens a plane by the equation ax + by + cz + d = 0
  3566. */
  3567. export class Plane {
  3568. /**
  3569. * Normal of the plane (a,b,c)
  3570. */
  3571. normal: Vector3;
  3572. /**
  3573. * d component of the plane
  3574. */
  3575. d: number;
  3576. /**
  3577. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3578. * @param a a component of the plane
  3579. * @param b b component of the plane
  3580. * @param c c component of the plane
  3581. * @param d d component of the plane
  3582. */
  3583. constructor(a: number, b: number, c: number, d: number);
  3584. /**
  3585. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3586. */
  3587. asArray(): number[];
  3588. /**
  3589. * @returns a new plane copied from the current Plane.
  3590. */
  3591. clone(): Plane;
  3592. /**
  3593. * @returns the string "Plane".
  3594. */
  3595. getClassName(): string;
  3596. /**
  3597. * @returns the Plane hash code.
  3598. */
  3599. getHashCode(): number;
  3600. /**
  3601. * Normalize the current Plane in place.
  3602. * @returns the updated Plane.
  3603. */
  3604. normalize(): Plane;
  3605. /**
  3606. * Applies a transformation the plane and returns the result
  3607. * @param transformation the transformation matrix to be applied to the plane
  3608. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3609. */
  3610. transform(transformation: DeepImmutable<Matrix>): Plane;
  3611. /**
  3612. * Calcualtte the dot product between the point and the plane normal
  3613. * @param point point to calculate the dot product with
  3614. * @returns the dot product (float) of the point coordinates and the plane normal.
  3615. */
  3616. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3617. /**
  3618. * Updates the current Plane from the plane defined by the three given points.
  3619. * @param point1 one of the points used to contruct the plane
  3620. * @param point2 one of the points used to contruct the plane
  3621. * @param point3 one of the points used to contruct the plane
  3622. * @returns the updated Plane.
  3623. */
  3624. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3625. /**
  3626. * Checks if the plane is facing a given direction
  3627. * @param direction the direction to check if the plane is facing
  3628. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3629. * @returns True is the vector "direction" is the same side than the plane normal.
  3630. */
  3631. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3632. /**
  3633. * Calculates the distance to a point
  3634. * @param point point to calculate distance to
  3635. * @returns the signed distance (float) from the given point to the Plane.
  3636. */
  3637. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3638. /**
  3639. * Creates a plane from an array
  3640. * @param array the array to create a plane from
  3641. * @returns a new Plane from the given array.
  3642. */
  3643. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3644. /**
  3645. * Creates a plane from three points
  3646. * @param point1 point used to create the plane
  3647. * @param point2 point used to create the plane
  3648. * @param point3 point used to create the plane
  3649. * @returns a new Plane defined by the three given points.
  3650. */
  3651. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3652. /**
  3653. * Creates a plane from an origin point and a normal
  3654. * @param origin origin of the plane to be constructed
  3655. * @param normal normal of the plane to be constructed
  3656. * @returns a new Plane the normal vector to this plane at the given origin point.
  3657. * Note : the vector "normal" is updated because normalized.
  3658. */
  3659. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3660. /**
  3661. * Calculates the distance from a plane and a point
  3662. * @param origin origin of the plane to be constructed
  3663. * @param normal normal of the plane to be constructed
  3664. * @param point point to calculate distance to
  3665. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3666. */
  3667. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3668. }
  3669. /**
  3670. * Class used to represent a viewport on screen
  3671. */
  3672. export class Viewport {
  3673. /** viewport left coordinate */
  3674. x: number;
  3675. /** viewport top coordinate */
  3676. y: number;
  3677. /**viewport width */
  3678. width: number;
  3679. /** viewport height */
  3680. height: number;
  3681. /**
  3682. * Creates a Viewport object located at (x, y) and sized (width, height)
  3683. * @param x defines viewport left coordinate
  3684. * @param y defines viewport top coordinate
  3685. * @param width defines the viewport width
  3686. * @param height defines the viewport height
  3687. */
  3688. constructor(
  3689. /** viewport left coordinate */
  3690. x: number,
  3691. /** viewport top coordinate */
  3692. y: number,
  3693. /**viewport width */
  3694. width: number,
  3695. /** viewport height */
  3696. height: number);
  3697. /**
  3698. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3699. * @param renderWidth defines the rendering width
  3700. * @param renderHeight defines the rendering height
  3701. * @returns a new Viewport
  3702. */
  3703. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3704. /**
  3705. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3706. * @param renderWidth defines the rendering width
  3707. * @param renderHeight defines the rendering height
  3708. * @param ref defines the target viewport
  3709. * @returns the current viewport
  3710. */
  3711. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3712. /**
  3713. * Returns a new Viewport copied from the current one
  3714. * @returns a new Viewport
  3715. */
  3716. clone(): Viewport;
  3717. }
  3718. /**
  3719. * Reprasents a camera frustum
  3720. */
  3721. export class Frustum {
  3722. /**
  3723. * Gets the planes representing the frustum
  3724. * @param transform matrix to be applied to the returned planes
  3725. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3726. */
  3727. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3728. /**
  3729. * Gets the near frustum plane transformed by the transform matrix
  3730. * @param transform transformation matrix to be applied to the resulting frustum plane
  3731. * @param frustumPlane the resuling frustum plane
  3732. */
  3733. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3734. /**
  3735. * Gets the far frustum plane transformed by the transform matrix
  3736. * @param transform transformation matrix to be applied to the resulting frustum plane
  3737. * @param frustumPlane the resuling frustum plane
  3738. */
  3739. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3740. /**
  3741. * Gets the left frustum plane transformed by the transform matrix
  3742. * @param transform transformation matrix to be applied to the resulting frustum plane
  3743. * @param frustumPlane the resuling frustum plane
  3744. */
  3745. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3746. /**
  3747. * Gets the right frustum plane transformed by the transform matrix
  3748. * @param transform transformation matrix to be applied to the resulting frustum plane
  3749. * @param frustumPlane the resuling frustum plane
  3750. */
  3751. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3752. /**
  3753. * Gets the top frustum plane transformed by the transform matrix
  3754. * @param transform transformation matrix to be applied to the resulting frustum plane
  3755. * @param frustumPlane the resuling frustum plane
  3756. */
  3757. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3758. /**
  3759. * Gets the bottom frustum plane transformed by the transform matrix
  3760. * @param transform transformation matrix to be applied to the resulting frustum plane
  3761. * @param frustumPlane the resuling frustum plane
  3762. */
  3763. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3764. /**
  3765. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3766. * @param transform transformation matrix to be applied to the resulting frustum planes
  3767. * @param frustumPlanes the resuling frustum planes
  3768. */
  3769. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3770. }
  3771. /** Defines supported spaces */
  3772. export enum Space {
  3773. /** Local (object) space */
  3774. LOCAL = 0,
  3775. /** World space */
  3776. WORLD = 1,
  3777. /** Bone space */
  3778. BONE = 2
  3779. }
  3780. /** Defines the 3 main axes */
  3781. export class Axis {
  3782. /** X axis */
  3783. static X: Vector3;
  3784. /** Y axis */
  3785. static Y: Vector3;
  3786. /** Z axis */
  3787. static Z: Vector3;
  3788. }
  3789. /** Class used to represent a Bezier curve */
  3790. export class BezierCurve {
  3791. /**
  3792. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3793. * @param t defines the time
  3794. * @param x1 defines the left coordinate on X axis
  3795. * @param y1 defines the left coordinate on Y axis
  3796. * @param x2 defines the right coordinate on X axis
  3797. * @param y2 defines the right coordinate on Y axis
  3798. * @returns the interpolated value
  3799. */
  3800. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3801. }
  3802. /**
  3803. * Defines potential orientation for back face culling
  3804. */
  3805. export enum Orientation {
  3806. /**
  3807. * Clockwise
  3808. */
  3809. CW = 0,
  3810. /** Counter clockwise */
  3811. CCW = 1
  3812. }
  3813. /**
  3814. * Defines angle representation
  3815. */
  3816. export class Angle {
  3817. private _radians;
  3818. /**
  3819. * Creates an Angle object of "radians" radians (float).
  3820. * @param radians the angle in radians
  3821. */
  3822. constructor(radians: number);
  3823. /**
  3824. * Get value in degrees
  3825. * @returns the Angle value in degrees (float)
  3826. */
  3827. degrees(): number;
  3828. /**
  3829. * Get value in radians
  3830. * @returns the Angle value in radians (float)
  3831. */
  3832. radians(): number;
  3833. /**
  3834. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3835. * @param a defines first vector
  3836. * @param b defines second vector
  3837. * @returns a new Angle
  3838. */
  3839. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3840. /**
  3841. * Gets a new Angle object from the given float in radians
  3842. * @param radians defines the angle value in radians
  3843. * @returns a new Angle
  3844. */
  3845. static FromRadians(radians: number): Angle;
  3846. /**
  3847. * Gets a new Angle object from the given float in degrees
  3848. * @param degrees defines the angle value in degrees
  3849. * @returns a new Angle
  3850. */
  3851. static FromDegrees(degrees: number): Angle;
  3852. }
  3853. /**
  3854. * This represents an arc in a 2d space.
  3855. */
  3856. export class Arc2 {
  3857. /** Defines the start point of the arc */
  3858. startPoint: Vector2;
  3859. /** Defines the mid point of the arc */
  3860. midPoint: Vector2;
  3861. /** Defines the end point of the arc */
  3862. endPoint: Vector2;
  3863. /**
  3864. * Defines the center point of the arc.
  3865. */
  3866. centerPoint: Vector2;
  3867. /**
  3868. * Defines the radius of the arc.
  3869. */
  3870. radius: number;
  3871. /**
  3872. * Defines the angle of the arc (from mid point to end point).
  3873. */
  3874. angle: Angle;
  3875. /**
  3876. * Defines the start angle of the arc (from start point to middle point).
  3877. */
  3878. startAngle: Angle;
  3879. /**
  3880. * Defines the orientation of the arc (clock wise/counter clock wise).
  3881. */
  3882. orientation: Orientation;
  3883. /**
  3884. * Creates an Arc object from the three given points : start, middle and end.
  3885. * @param startPoint Defines the start point of the arc
  3886. * @param midPoint Defines the midlle point of the arc
  3887. * @param endPoint Defines the end point of the arc
  3888. */
  3889. constructor(
  3890. /** Defines the start point of the arc */
  3891. startPoint: Vector2,
  3892. /** Defines the mid point of the arc */
  3893. midPoint: Vector2,
  3894. /** Defines the end point of the arc */
  3895. endPoint: Vector2);
  3896. }
  3897. /**
  3898. * Represents a 2D path made up of multiple 2D points
  3899. */
  3900. export class Path2 {
  3901. private _points;
  3902. private _length;
  3903. /**
  3904. * If the path start and end point are the same
  3905. */
  3906. closed: boolean;
  3907. /**
  3908. * Creates a Path2 object from the starting 2D coordinates x and y.
  3909. * @param x the starting points x value
  3910. * @param y the starting points y value
  3911. */
  3912. constructor(x: number, y: number);
  3913. /**
  3914. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3915. * @param x the added points x value
  3916. * @param y the added points y value
  3917. * @returns the updated Path2.
  3918. */
  3919. addLineTo(x: number, y: number): Path2;
  3920. /**
  3921. * 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.
  3922. * @param midX middle point x value
  3923. * @param midY middle point y value
  3924. * @param endX end point x value
  3925. * @param endY end point y value
  3926. * @param numberOfSegments (default: 36)
  3927. * @returns the updated Path2.
  3928. */
  3929. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3930. /**
  3931. * Closes the Path2.
  3932. * @returns the Path2.
  3933. */
  3934. close(): Path2;
  3935. /**
  3936. * Gets the sum of the distance between each sequential point in the path
  3937. * @returns the Path2 total length (float).
  3938. */
  3939. length(): number;
  3940. /**
  3941. * Gets the points which construct the path
  3942. * @returns the Path2 internal array of points.
  3943. */
  3944. getPoints(): Vector2[];
  3945. /**
  3946. * Retreives the point at the distance aways from the starting point
  3947. * @param normalizedLengthPosition the length along the path to retreive the point from
  3948. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3949. */
  3950. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3951. /**
  3952. * Creates a new path starting from an x and y position
  3953. * @param x starting x value
  3954. * @param y starting y value
  3955. * @returns a new Path2 starting at the coordinates (x, y).
  3956. */
  3957. static StartingAt(x: number, y: number): Path2;
  3958. }
  3959. /**
  3960. * Represents a 3D path made up of multiple 3D points
  3961. */
  3962. export class Path3D {
  3963. /**
  3964. * an array of Vector3, the curve axis of the Path3D
  3965. */
  3966. path: Vector3[];
  3967. private _curve;
  3968. private _distances;
  3969. private _tangents;
  3970. private _normals;
  3971. private _binormals;
  3972. private _raw;
  3973. /**
  3974. * new Path3D(path, normal, raw)
  3975. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3976. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3977. * @param path an array of Vector3, the curve axis of the Path3D
  3978. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3979. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3980. */
  3981. constructor(
  3982. /**
  3983. * an array of Vector3, the curve axis of the Path3D
  3984. */
  3985. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3986. /**
  3987. * Returns the Path3D array of successive Vector3 designing its curve.
  3988. * @returns the Path3D array of successive Vector3 designing its curve.
  3989. */
  3990. getCurve(): Vector3[];
  3991. /**
  3992. * Returns an array populated with tangent vectors on each Path3D curve point.
  3993. * @returns an array populated with tangent vectors on each Path3D curve point.
  3994. */
  3995. getTangents(): Vector3[];
  3996. /**
  3997. * Returns an array populated with normal vectors on each Path3D curve point.
  3998. * @returns an array populated with normal vectors on each Path3D curve point.
  3999. */
  4000. getNormals(): Vector3[];
  4001. /**
  4002. * Returns an array populated with binormal vectors on each Path3D curve point.
  4003. * @returns an array populated with binormal vectors on each Path3D curve point.
  4004. */
  4005. getBinormals(): Vector3[];
  4006. /**
  4007. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4008. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4009. */
  4010. getDistances(): number[];
  4011. /**
  4012. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4013. * @param path path which all values are copied into the curves points
  4014. * @param firstNormal which should be projected onto the curve
  4015. * @returns the same object updated.
  4016. */
  4017. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4018. private _compute;
  4019. private _getFirstNonNullVector;
  4020. private _getLastNonNullVector;
  4021. private _normalVector;
  4022. }
  4023. /**
  4024. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4025. * A Curve3 is designed from a series of successive Vector3.
  4026. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4027. */
  4028. export class Curve3 {
  4029. private _points;
  4030. private _length;
  4031. /**
  4032. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4033. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4034. * @param v1 (Vector3) the control point
  4035. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4036. * @param nbPoints (integer) the wanted number of points in the curve
  4037. * @returns the created Curve3
  4038. */
  4039. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4040. /**
  4041. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4042. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4043. * @param v1 (Vector3) the first control point
  4044. * @param v2 (Vector3) the second control point
  4045. * @param v3 (Vector3) the end point of the Cubic Bezier
  4046. * @param nbPoints (integer) the wanted number of points in the curve
  4047. * @returns the created Curve3
  4048. */
  4049. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4050. /**
  4051. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4052. * @param p1 (Vector3) the origin point of the Hermite Spline
  4053. * @param t1 (Vector3) the tangent vector at the origin point
  4054. * @param p2 (Vector3) the end point of the Hermite Spline
  4055. * @param t2 (Vector3) the tangent vector at the end point
  4056. * @param nbPoints (integer) the wanted number of points in the curve
  4057. * @returns the created Curve3
  4058. */
  4059. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4060. /**
  4061. * Returns a Curve3 object along a CatmullRom Spline curve :
  4062. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4063. * @param nbPoints (integer) the wanted number of points between each curve control points
  4064. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4065. * @returns the created Curve3
  4066. */
  4067. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4068. /**
  4069. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4070. * A Curve3 is designed from a series of successive Vector3.
  4071. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4072. * @param points points which make up the curve
  4073. */
  4074. constructor(points: Vector3[]);
  4075. /**
  4076. * @returns the Curve3 stored array of successive Vector3
  4077. */
  4078. getPoints(): Vector3[];
  4079. /**
  4080. * @returns the computed length (float) of the curve.
  4081. */
  4082. length(): number;
  4083. /**
  4084. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4085. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4086. * curveA and curveB keep unchanged.
  4087. * @param curve the curve to continue from this curve
  4088. * @returns the newly constructed curve
  4089. */
  4090. continue(curve: DeepImmutable<Curve3>): Curve3;
  4091. private _computeLength;
  4092. }
  4093. /**
  4094. * Contains position and normal vectors for a vertex
  4095. */
  4096. export class PositionNormalVertex {
  4097. /** the position of the vertex (defaut: 0,0,0) */
  4098. position: Vector3;
  4099. /** the normal of the vertex (defaut: 0,1,0) */
  4100. normal: Vector3;
  4101. /**
  4102. * Creates a PositionNormalVertex
  4103. * @param position the position of the vertex (defaut: 0,0,0)
  4104. * @param normal the normal of the vertex (defaut: 0,1,0)
  4105. */
  4106. constructor(
  4107. /** the position of the vertex (defaut: 0,0,0) */
  4108. position?: Vector3,
  4109. /** the normal of the vertex (defaut: 0,1,0) */
  4110. normal?: Vector3);
  4111. /**
  4112. * Clones the PositionNormalVertex
  4113. * @returns the cloned PositionNormalVertex
  4114. */
  4115. clone(): PositionNormalVertex;
  4116. }
  4117. /**
  4118. * Contains position, normal and uv vectors for a vertex
  4119. */
  4120. export class PositionNormalTextureVertex {
  4121. /** the position of the vertex (defaut: 0,0,0) */
  4122. position: Vector3;
  4123. /** the normal of the vertex (defaut: 0,1,0) */
  4124. normal: Vector3;
  4125. /** the uv of the vertex (default: 0,0) */
  4126. uv: Vector2;
  4127. /**
  4128. * Creates a PositionNormalTextureVertex
  4129. * @param position the position of the vertex (defaut: 0,0,0)
  4130. * @param normal the normal of the vertex (defaut: 0,1,0)
  4131. * @param uv the uv of the vertex (default: 0,0)
  4132. */
  4133. constructor(
  4134. /** the position of the vertex (defaut: 0,0,0) */
  4135. position?: Vector3,
  4136. /** the normal of the vertex (defaut: 0,1,0) */
  4137. normal?: Vector3,
  4138. /** the uv of the vertex (default: 0,0) */
  4139. uv?: Vector2);
  4140. /**
  4141. * Clones the PositionNormalTextureVertex
  4142. * @returns the cloned PositionNormalTextureVertex
  4143. */
  4144. clone(): PositionNormalTextureVertex;
  4145. }
  4146. /**
  4147. * @hidden
  4148. */
  4149. export class Tmp {
  4150. static Color3: Color3[];
  4151. static Color4: Color4[];
  4152. static Vector2: Vector2[];
  4153. static Vector3: Vector3[];
  4154. static Vector4: Vector4[];
  4155. static Quaternion: Quaternion[];
  4156. static Matrix: Matrix[];
  4157. }
  4158. }
  4159. declare module BABYLON {
  4160. /**
  4161. * Class used to enable access to offline support
  4162. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4163. */
  4164. export interface IOfflineProvider {
  4165. /**
  4166. * Gets a boolean indicating if scene must be saved in the database
  4167. */
  4168. enableSceneOffline: boolean;
  4169. /**
  4170. * Gets a boolean indicating if textures must be saved in the database
  4171. */
  4172. enableTexturesOffline: boolean;
  4173. /**
  4174. * Open the offline support and make it available
  4175. * @param successCallback defines the callback to call on success
  4176. * @param errorCallback defines the callback to call on error
  4177. */
  4178. open(successCallback: () => void, errorCallback: () => void): void;
  4179. /**
  4180. * Loads an image from the offline support
  4181. * @param url defines the url to load from
  4182. * @param image defines the target DOM image
  4183. */
  4184. loadImage(url: string, image: HTMLImageElement): void;
  4185. /**
  4186. * Loads a file from offline support
  4187. * @param url defines the URL to load from
  4188. * @param sceneLoaded defines a callback to call on success
  4189. * @param progressCallBack defines a callback to call when progress changed
  4190. * @param errorCallback defines a callback to call on error
  4191. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4192. */
  4193. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4194. }
  4195. }
  4196. declare module BABYLON {
  4197. /**
  4198. * A class serves as a medium between the observable and its observers
  4199. */
  4200. export class EventState {
  4201. /**
  4202. * Create a new EventState
  4203. * @param mask defines the mask associated with this state
  4204. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4205. * @param target defines the original target of the state
  4206. * @param currentTarget defines the current target of the state
  4207. */
  4208. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4209. /**
  4210. * Initialize the current event state
  4211. * @param mask defines the mask associated with this state
  4212. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4213. * @param target defines the original target of the state
  4214. * @param currentTarget defines the current target of the state
  4215. * @returns the current event state
  4216. */
  4217. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4218. /**
  4219. * An Observer can set this property to true to prevent subsequent observers of being notified
  4220. */
  4221. skipNextObservers: boolean;
  4222. /**
  4223. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4224. */
  4225. mask: number;
  4226. /**
  4227. * The object that originally notified the event
  4228. */
  4229. target?: any;
  4230. /**
  4231. * The current object in the bubbling phase
  4232. */
  4233. currentTarget?: any;
  4234. /**
  4235. * This will be populated with the return value of the last function that was executed.
  4236. * If it is the first function in the callback chain it will be the event data.
  4237. */
  4238. lastReturnValue?: any;
  4239. }
  4240. /**
  4241. * Represent an Observer registered to a given Observable object.
  4242. */
  4243. export class Observer<T> {
  4244. /**
  4245. * Defines the callback to call when the observer is notified
  4246. */
  4247. callback: (eventData: T, eventState: EventState) => void;
  4248. /**
  4249. * Defines the mask of the observer (used to filter notifications)
  4250. */
  4251. mask: number;
  4252. /**
  4253. * Defines the current scope used to restore the JS context
  4254. */
  4255. scope: any;
  4256. /** @hidden */ willBeUnregistered: boolean;
  4257. /**
  4258. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4259. */
  4260. unregisterOnNextCall: boolean;
  4261. /**
  4262. * Creates a new observer
  4263. * @param callback defines the callback to call when the observer is notified
  4264. * @param mask defines the mask of the observer (used to filter notifications)
  4265. * @param scope defines the current scope used to restore the JS context
  4266. */
  4267. constructor(
  4268. /**
  4269. * Defines the callback to call when the observer is notified
  4270. */
  4271. callback: (eventData: T, eventState: EventState) => void,
  4272. /**
  4273. * Defines the mask of the observer (used to filter notifications)
  4274. */
  4275. mask: number,
  4276. /**
  4277. * Defines the current scope used to restore the JS context
  4278. */
  4279. scope?: any);
  4280. }
  4281. /**
  4282. * Represent a list of observers registered to multiple Observables object.
  4283. */
  4284. export class MultiObserver<T> {
  4285. private _observers;
  4286. private _observables;
  4287. /**
  4288. * Release associated resources
  4289. */
  4290. dispose(): void;
  4291. /**
  4292. * Raise a callback when one of the observable will notify
  4293. * @param observables defines a list of observables to watch
  4294. * @param callback defines the callback to call on notification
  4295. * @param mask defines the mask used to filter notifications
  4296. * @param scope defines the current scope used to restore the JS context
  4297. * @returns the new MultiObserver
  4298. */
  4299. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4300. }
  4301. /**
  4302. * The Observable class is a simple implementation of the Observable pattern.
  4303. *
  4304. * 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.
  4305. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4306. * 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).
  4307. * 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.
  4308. */
  4309. export class Observable<T> {
  4310. private _observers;
  4311. private _eventState;
  4312. private _onObserverAdded;
  4313. /**
  4314. * Creates a new observable
  4315. * @param onObserverAdded defines a callback to call when a new observer is added
  4316. */
  4317. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4318. /**
  4319. * Create a new Observer with the specified callback
  4320. * @param callback the callback that will be executed for that Observer
  4321. * @param mask the mask used to filter observers
  4322. * @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.
  4323. * @param scope optional scope for the callback to be called from
  4324. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4325. * @returns the new observer created for the callback
  4326. */
  4327. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4328. /**
  4329. * Create a new Observer with the specified callback and unregisters after the next notification
  4330. * @param callback the callback that will be executed for that Observer
  4331. * @returns the new observer created for the callback
  4332. */
  4333. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4334. /**
  4335. * Remove an Observer from the Observable object
  4336. * @param observer the instance of the Observer to remove
  4337. * @returns false if it doesn't belong to this Observable
  4338. */
  4339. remove(observer: Nullable<Observer<T>>): boolean;
  4340. /**
  4341. * Remove a callback from the Observable object
  4342. * @param callback the callback to remove
  4343. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4344. * @returns false if it doesn't belong to this Observable
  4345. */
  4346. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4347. private _deferUnregister;
  4348. private _remove;
  4349. /**
  4350. * Moves the observable to the top of the observer list making it get called first when notified
  4351. * @param observer the observer to move
  4352. */
  4353. makeObserverTopPriority(observer: Observer<T>): void;
  4354. /**
  4355. * Moves the observable to the bottom of the observer list making it get called last when notified
  4356. * @param observer the observer to move
  4357. */
  4358. makeObserverBottomPriority(observer: Observer<T>): void;
  4359. /**
  4360. * Notify all Observers by calling their respective callback with the given data
  4361. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4362. * @param eventData defines the data to send to all observers
  4363. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4364. * @param target defines the original target of the state
  4365. * @param currentTarget defines the current target of the state
  4366. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4367. */
  4368. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4369. /**
  4370. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4371. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4372. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4373. * and it is crucial that all callbacks will be executed.
  4374. * The order of the callbacks is kept, callbacks are not executed parallel.
  4375. *
  4376. * @param eventData The data to be sent to each callback
  4377. * @param mask is used to filter observers defaults to -1
  4378. * @param target defines the callback target (see EventState)
  4379. * @param currentTarget defines he current object in the bubbling phase
  4380. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4381. */
  4382. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4383. /**
  4384. * Notify a specific observer
  4385. * @param observer defines the observer to notify
  4386. * @param eventData defines the data to be sent to each callback
  4387. * @param mask is used to filter observers defaults to -1
  4388. */
  4389. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4390. /**
  4391. * Gets a boolean indicating if the observable has at least one observer
  4392. * @returns true is the Observable has at least one Observer registered
  4393. */
  4394. hasObservers(): boolean;
  4395. /**
  4396. * Clear the list of observers
  4397. */
  4398. clear(): void;
  4399. /**
  4400. * Clone the current observable
  4401. * @returns a new observable
  4402. */
  4403. clone(): Observable<T>;
  4404. /**
  4405. * Does this observable handles observer registered with a given mask
  4406. * @param mask defines the mask to be tested
  4407. * @return whether or not one observer registered with the given mask is handeled
  4408. **/
  4409. hasSpecificMask(mask?: number): boolean;
  4410. }
  4411. }
  4412. declare module BABYLON {
  4413. /**
  4414. * Class used to help managing file picking and drag'n'drop
  4415. * File Storage
  4416. */
  4417. export class FilesInputStore {
  4418. /**
  4419. * List of files ready to be loaded
  4420. */
  4421. static FilesToLoad: {
  4422. [key: string]: File;
  4423. };
  4424. }
  4425. }
  4426. declare module BABYLON {
  4427. /** Defines the cross module used constants to avoid circular dependncies */
  4428. export class Constants {
  4429. /** Defines that alpha blending is disabled */
  4430. static readonly ALPHA_DISABLE: number;
  4431. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4432. static readonly ALPHA_ADD: number;
  4433. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4434. static readonly ALPHA_COMBINE: number;
  4435. /** Defines that alpha blending to DEST - SRC * DEST */
  4436. static readonly ALPHA_SUBTRACT: number;
  4437. /** Defines that alpha blending to SRC * DEST */
  4438. static readonly ALPHA_MULTIPLY: number;
  4439. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4440. static readonly ALPHA_MAXIMIZED: number;
  4441. /** Defines that alpha blending to SRC + DEST */
  4442. static readonly ALPHA_ONEONE: number;
  4443. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4444. static readonly ALPHA_PREMULTIPLIED: number;
  4445. /**
  4446. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4447. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4448. */
  4449. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4450. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4451. static readonly ALPHA_INTERPOLATE: number;
  4452. /**
  4453. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4454. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4455. */
  4456. static readonly ALPHA_SCREENMODE: number;
  4457. /** Defines that the ressource is not delayed*/
  4458. static readonly DELAYLOADSTATE_NONE: number;
  4459. /** Defines that the ressource was successfully delay loaded */
  4460. static readonly DELAYLOADSTATE_LOADED: number;
  4461. /** Defines that the ressource is currently delay loading */
  4462. static readonly DELAYLOADSTATE_LOADING: number;
  4463. /** Defines that the ressource is delayed and has not started loading */
  4464. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4465. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4466. static readonly NEVER: number;
  4467. /** 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 */
  4468. static readonly ALWAYS: number;
  4469. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4470. static readonly LESS: number;
  4471. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4472. static readonly EQUAL: number;
  4473. /** 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 */
  4474. static readonly LEQUAL: number;
  4475. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4476. static readonly GREATER: number;
  4477. /** 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 */
  4478. static readonly GEQUAL: number;
  4479. /** 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 */
  4480. static readonly NOTEQUAL: number;
  4481. /** Passed to stencilOperation to specify that stencil value must be kept */
  4482. static readonly KEEP: number;
  4483. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4484. static readonly REPLACE: number;
  4485. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4486. static readonly INCR: number;
  4487. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4488. static readonly DECR: number;
  4489. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4490. static readonly INVERT: number;
  4491. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4492. static readonly INCR_WRAP: number;
  4493. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4494. static readonly DECR_WRAP: number;
  4495. /** Texture is not repeating outside of 0..1 UVs */
  4496. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4497. /** Texture is repeating outside of 0..1 UVs */
  4498. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4499. /** Texture is repeating and mirrored */
  4500. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4501. /** ALPHA */
  4502. static readonly TEXTUREFORMAT_ALPHA: number;
  4503. /** LUMINANCE */
  4504. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4505. /** LUMINANCE_ALPHA */
  4506. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4507. /** RGB */
  4508. static readonly TEXTUREFORMAT_RGB: number;
  4509. /** RGBA */
  4510. static readonly TEXTUREFORMAT_RGBA: number;
  4511. /** RED */
  4512. static readonly TEXTUREFORMAT_RED: number;
  4513. /** RED (2nd reference) */
  4514. static readonly TEXTUREFORMAT_R: number;
  4515. /** RG */
  4516. static readonly TEXTUREFORMAT_RG: number;
  4517. /** RED_INTEGER */
  4518. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4519. /** RED_INTEGER (2nd reference) */
  4520. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4521. /** RG_INTEGER */
  4522. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4523. /** RGB_INTEGER */
  4524. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4525. /** RGBA_INTEGER */
  4526. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4527. /** UNSIGNED_BYTE */
  4528. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4529. /** UNSIGNED_BYTE (2nd reference) */
  4530. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4531. /** FLOAT */
  4532. static readonly TEXTURETYPE_FLOAT: number;
  4533. /** HALF_FLOAT */
  4534. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4535. /** BYTE */
  4536. static readonly TEXTURETYPE_BYTE: number;
  4537. /** SHORT */
  4538. static readonly TEXTURETYPE_SHORT: number;
  4539. /** UNSIGNED_SHORT */
  4540. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4541. /** INT */
  4542. static readonly TEXTURETYPE_INT: number;
  4543. /** UNSIGNED_INT */
  4544. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4545. /** UNSIGNED_SHORT_4_4_4_4 */
  4546. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4547. /** UNSIGNED_SHORT_5_5_5_1 */
  4548. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4549. /** UNSIGNED_SHORT_5_6_5 */
  4550. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4551. /** UNSIGNED_INT_2_10_10_10_REV */
  4552. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4553. /** UNSIGNED_INT_24_8 */
  4554. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4555. /** UNSIGNED_INT_10F_11F_11F_REV */
  4556. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4557. /** UNSIGNED_INT_5_9_9_9_REV */
  4558. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4559. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4560. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4561. /** nearest is mag = nearest and min = nearest and mip = linear */
  4562. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4563. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4564. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4565. /** Trilinear is mag = linear and min = linear and mip = linear */
  4566. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4567. /** nearest is mag = nearest and min = nearest and mip = linear */
  4568. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4569. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4570. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4571. /** Trilinear is mag = linear and min = linear and mip = linear */
  4572. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4573. /** mag = nearest and min = nearest and mip = nearest */
  4574. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4575. /** mag = nearest and min = linear and mip = nearest */
  4576. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4577. /** mag = nearest and min = linear and mip = linear */
  4578. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4579. /** mag = nearest and min = linear and mip = none */
  4580. static readonly TEXTURE_NEAREST_LINEAR: number;
  4581. /** mag = nearest and min = nearest and mip = none */
  4582. static readonly TEXTURE_NEAREST_NEAREST: number;
  4583. /** mag = linear and min = nearest and mip = nearest */
  4584. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4585. /** mag = linear and min = nearest and mip = linear */
  4586. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4587. /** mag = linear and min = linear and mip = none */
  4588. static readonly TEXTURE_LINEAR_LINEAR: number;
  4589. /** mag = linear and min = nearest and mip = none */
  4590. static readonly TEXTURE_LINEAR_NEAREST: number;
  4591. /** Explicit coordinates mode */
  4592. static readonly TEXTURE_EXPLICIT_MODE: number;
  4593. /** Spherical coordinates mode */
  4594. static readonly TEXTURE_SPHERICAL_MODE: number;
  4595. /** Planar coordinates mode */
  4596. static readonly TEXTURE_PLANAR_MODE: number;
  4597. /** Cubic coordinates mode */
  4598. static readonly TEXTURE_CUBIC_MODE: number;
  4599. /** Projection coordinates mode */
  4600. static readonly TEXTURE_PROJECTION_MODE: number;
  4601. /** Skybox coordinates mode */
  4602. static readonly TEXTURE_SKYBOX_MODE: number;
  4603. /** Inverse Cubic coordinates mode */
  4604. static readonly TEXTURE_INVCUBIC_MODE: number;
  4605. /** Equirectangular coordinates mode */
  4606. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4607. /** Equirectangular Fixed coordinates mode */
  4608. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4609. /** Equirectangular Fixed Mirrored coordinates mode */
  4610. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4611. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4612. static readonly SCALEMODE_FLOOR: number;
  4613. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4614. static readonly SCALEMODE_NEAREST: number;
  4615. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4616. static readonly SCALEMODE_CEILING: number;
  4617. /**
  4618. * The dirty texture flag value
  4619. */
  4620. static readonly MATERIAL_TextureDirtyFlag: number;
  4621. /**
  4622. * The dirty light flag value
  4623. */
  4624. static readonly MATERIAL_LightDirtyFlag: number;
  4625. /**
  4626. * The dirty fresnel flag value
  4627. */
  4628. static readonly MATERIAL_FresnelDirtyFlag: number;
  4629. /**
  4630. * The dirty attribute flag value
  4631. */
  4632. static readonly MATERIAL_AttributesDirtyFlag: number;
  4633. /**
  4634. * The dirty misc flag value
  4635. */
  4636. static readonly MATERIAL_MiscDirtyFlag: number;
  4637. /**
  4638. * The all dirty flag value
  4639. */
  4640. static readonly MATERIAL_AllDirtyFlag: number;
  4641. /**
  4642. * Returns the triangle fill mode
  4643. */
  4644. static readonly MATERIAL_TriangleFillMode: number;
  4645. /**
  4646. * Returns the wireframe mode
  4647. */
  4648. static readonly MATERIAL_WireFrameFillMode: number;
  4649. /**
  4650. * Returns the point fill mode
  4651. */
  4652. static readonly MATERIAL_PointFillMode: number;
  4653. /**
  4654. * Returns the point list draw mode
  4655. */
  4656. static readonly MATERIAL_PointListDrawMode: number;
  4657. /**
  4658. * Returns the line list draw mode
  4659. */
  4660. static readonly MATERIAL_LineListDrawMode: number;
  4661. /**
  4662. * Returns the line loop draw mode
  4663. */
  4664. static readonly MATERIAL_LineLoopDrawMode: number;
  4665. /**
  4666. * Returns the line strip draw mode
  4667. */
  4668. static readonly MATERIAL_LineStripDrawMode: number;
  4669. /**
  4670. * Returns the triangle strip draw mode
  4671. */
  4672. static readonly MATERIAL_TriangleStripDrawMode: number;
  4673. /**
  4674. * Returns the triangle fan draw mode
  4675. */
  4676. static readonly MATERIAL_TriangleFanDrawMode: number;
  4677. /**
  4678. * Stores the clock-wise side orientation
  4679. */
  4680. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4681. /**
  4682. * Stores the counter clock-wise side orientation
  4683. */
  4684. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4685. /**
  4686. * Nothing
  4687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4688. */
  4689. static readonly ACTION_NothingTrigger: number;
  4690. /**
  4691. * On pick
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_OnPickTrigger: number;
  4695. /**
  4696. * On left pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnLeftPickTrigger: number;
  4700. /**
  4701. * On right pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnRightPickTrigger: number;
  4705. /**
  4706. * On center pick
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnCenterPickTrigger: number;
  4710. /**
  4711. * On pick down
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnPickDownTrigger: number;
  4715. /**
  4716. * On double pick
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnDoublePickTrigger: number;
  4720. /**
  4721. * On pick up
  4722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4723. */
  4724. static readonly ACTION_OnPickUpTrigger: number;
  4725. /**
  4726. * On pick out.
  4727. * This trigger will only be raised if you also declared a OnPickDown
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnPickOutTrigger: number;
  4731. /**
  4732. * On long press
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnLongPressTrigger: number;
  4736. /**
  4737. * On pointer over
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPointerOverTrigger: number;
  4741. /**
  4742. * On pointer out
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnPointerOutTrigger: number;
  4746. /**
  4747. * On every frame
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnEveryFrameTrigger: number;
  4751. /**
  4752. * On intersection enter
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4756. /**
  4757. * On intersection exit
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnIntersectionExitTrigger: number;
  4761. /**
  4762. * On key down
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnKeyDownTrigger: number;
  4766. /**
  4767. * On key up
  4768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4769. */
  4770. static readonly ACTION_OnKeyUpTrigger: number;
  4771. /**
  4772. * Billboard mode will only apply to Y axis
  4773. */
  4774. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4775. /**
  4776. * Billboard mode will apply to all axes
  4777. */
  4778. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4779. /**
  4780. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4781. */
  4782. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4783. /**
  4784. * Gets or sets base Assets URL
  4785. */
  4786. static readonly PARTICLES_BaseAssetsUrl: string;
  4787. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4788. * Test order :
  4789. * Is the bounding sphere outside the frustum ?
  4790. * If not, are the bounding box vertices outside the frustum ?
  4791. * It not, then the cullable object is in the frustum.
  4792. */
  4793. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4794. /** Culling strategy : Bounding Sphere Only.
  4795. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4796. * It's also less accurate than the standard because some not visible objects can still be selected.
  4797. * Test : is the bounding sphere outside the frustum ?
  4798. * If not, then the cullable object is in the frustum.
  4799. */
  4800. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4801. /** Culling strategy : Optimistic Inclusion.
  4802. * This in an inclusion test first, then the standard exclusion test.
  4803. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4804. * 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.
  4805. * Anyway, it's as accurate as the standard strategy.
  4806. * Test :
  4807. * Is the cullable object bounding sphere center in the frustum ?
  4808. * If not, apply the default culling strategy.
  4809. */
  4810. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4811. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4812. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4813. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4814. * 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.
  4815. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4816. * Test :
  4817. * Is the cullable object bounding sphere center in the frustum ?
  4818. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4819. */
  4820. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4821. /**
  4822. * No logging while loading
  4823. */
  4824. static readonly SCENELOADER_NO_LOGGING: number;
  4825. /**
  4826. * Minimal logging while loading
  4827. */
  4828. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4829. /**
  4830. * Summary logging while loading
  4831. */
  4832. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4833. /**
  4834. * Detailled logging while loading
  4835. */
  4836. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4837. }
  4838. }
  4839. declare module BABYLON {
  4840. /**
  4841. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4842. * Babylon.js
  4843. */
  4844. export class DomManagement {
  4845. /**
  4846. * Checks if the window object exists
  4847. * @returns true if the window object exists
  4848. */
  4849. static IsWindowObjectExist(): boolean;
  4850. /**
  4851. * Extracts text content from a DOM element hierarchy
  4852. * @param element defines the root element
  4853. * @returns a string
  4854. */
  4855. static GetDOMTextContent(element: HTMLElement): string;
  4856. }
  4857. }
  4858. declare module BABYLON {
  4859. /**
  4860. * Logger used througouht the application to allow configuration of
  4861. * the log level required for the messages.
  4862. */
  4863. export class Logger {
  4864. /**
  4865. * No log
  4866. */
  4867. static readonly NoneLogLevel: number;
  4868. /**
  4869. * Only message logs
  4870. */
  4871. static readonly MessageLogLevel: number;
  4872. /**
  4873. * Only warning logs
  4874. */
  4875. static readonly WarningLogLevel: number;
  4876. /**
  4877. * Only error logs
  4878. */
  4879. static readonly ErrorLogLevel: number;
  4880. /**
  4881. * All logs
  4882. */
  4883. static readonly AllLogLevel: number;
  4884. private static _LogCache;
  4885. /**
  4886. * Gets a value indicating the number of loading errors
  4887. * @ignorenaming
  4888. */
  4889. static errorsCount: number;
  4890. /**
  4891. * Callback called when a new log is added
  4892. */
  4893. static OnNewCacheEntry: (entry: string) => void;
  4894. private static _AddLogEntry;
  4895. private static _FormatMessage;
  4896. private static _LogDisabled;
  4897. private static _LogEnabled;
  4898. private static _WarnDisabled;
  4899. private static _WarnEnabled;
  4900. private static _ErrorDisabled;
  4901. private static _ErrorEnabled;
  4902. /**
  4903. * Log a message to the console
  4904. */
  4905. static Log: (message: string) => void;
  4906. /**
  4907. * Write a warning message to the console
  4908. */
  4909. static Warn: (message: string) => void;
  4910. /**
  4911. * Write an error message to the console
  4912. */
  4913. static Error: (message: string) => void;
  4914. /**
  4915. * Gets current log cache (list of logs)
  4916. */
  4917. static readonly LogCache: string;
  4918. /**
  4919. * Clears the log cache
  4920. */
  4921. static ClearLogCache(): void;
  4922. /**
  4923. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4924. */
  4925. static LogLevels: number;
  4926. }
  4927. }
  4928. declare module BABYLON {
  4929. /** @hidden */
  4930. export class _TypeStore {
  4931. /** @hidden */
  4932. static RegisteredTypes: {
  4933. [key: string]: Object;
  4934. };
  4935. /** @hidden */
  4936. static GetClass(fqdn: string): any;
  4937. }
  4938. }
  4939. declare module BABYLON {
  4940. /**
  4941. * Class containing a set of static utilities functions for deep copy.
  4942. */
  4943. export class DeepCopier {
  4944. /**
  4945. * Tries to copy an object by duplicating every property
  4946. * @param source defines the source object
  4947. * @param destination defines the target object
  4948. * @param doNotCopyList defines a list of properties to avoid
  4949. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4950. */
  4951. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4952. }
  4953. }
  4954. declare module BABYLON {
  4955. /**
  4956. * Class containing a set of static utilities functions for precision date
  4957. */
  4958. export class PrecisionDate {
  4959. /**
  4960. * Gets either window.performance.now() if supported or Date.now() else
  4961. */
  4962. static readonly Now: number;
  4963. }
  4964. }
  4965. declare module BABYLON {
  4966. /** @hidden */
  4967. export class _DevTools {
  4968. static WarnImport(name: string): string;
  4969. }
  4970. }
  4971. declare module BABYLON {
  4972. /**
  4973. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4974. */
  4975. export class WebRequest {
  4976. private _xhr;
  4977. /**
  4978. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4979. * i.e. when loading files, where the server/service expects an Authorization header
  4980. */
  4981. static CustomRequestHeaders: {
  4982. [key: string]: string;
  4983. };
  4984. /**
  4985. * Add callback functions in this array to update all the requests before they get sent to the network
  4986. */
  4987. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  4988. private _injectCustomRequestHeaders;
  4989. /**
  4990. * Gets or sets a function to be called when loading progress changes
  4991. */
  4992. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  4993. /**
  4994. * Returns client's state
  4995. */
  4996. readonly readyState: number;
  4997. /**
  4998. * Returns client's status
  4999. */
  5000. readonly status: number;
  5001. /**
  5002. * Returns client's status as a text
  5003. */
  5004. readonly statusText: string;
  5005. /**
  5006. * Returns client's response
  5007. */
  5008. readonly response: any;
  5009. /**
  5010. * Returns client's response url
  5011. */
  5012. readonly responseURL: string;
  5013. /**
  5014. * Returns client's response as text
  5015. */
  5016. readonly responseText: string;
  5017. /**
  5018. * Gets or sets the expected response type
  5019. */
  5020. responseType: XMLHttpRequestResponseType;
  5021. /** @hidden */
  5022. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5023. /** @hidden */
  5024. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5025. /**
  5026. * Cancels any network activity
  5027. */
  5028. abort(): void;
  5029. /**
  5030. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5031. * @param body defines an optional request body
  5032. */
  5033. send(body?: Document | BodyInit | null): void;
  5034. /**
  5035. * Sets the request method, request URL
  5036. * @param method defines the method to use (GET, POST, etc..)
  5037. * @param url defines the url to connect with
  5038. */
  5039. open(method: string, url: string): void;
  5040. }
  5041. }
  5042. declare module BABYLON {
  5043. /**
  5044. * Class used to evalaute queries containing `and` and `or` operators
  5045. */
  5046. export class AndOrNotEvaluator {
  5047. /**
  5048. * Evaluate a query
  5049. * @param query defines the query to evaluate
  5050. * @param evaluateCallback defines the callback used to filter result
  5051. * @returns true if the query matches
  5052. */
  5053. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5054. private static _HandleParenthesisContent;
  5055. private static _SimplifyNegation;
  5056. }
  5057. }
  5058. declare module BABYLON {
  5059. /**
  5060. * Class used to store custom tags
  5061. */
  5062. export class Tags {
  5063. /**
  5064. * Adds support for tags on the given object
  5065. * @param obj defines the object to use
  5066. */
  5067. static EnableFor(obj: any): void;
  5068. /**
  5069. * Removes tags support
  5070. * @param obj defines the object to use
  5071. */
  5072. static DisableFor(obj: any): void;
  5073. /**
  5074. * Gets a boolean indicating if the given object has tags
  5075. * @param obj defines the object to use
  5076. * @returns a boolean
  5077. */
  5078. static HasTags(obj: any): boolean;
  5079. /**
  5080. * Gets the tags available on a given object
  5081. * @param obj defines the object to use
  5082. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5083. * @returns the tags
  5084. */
  5085. static GetTags(obj: any, asString?: boolean): any;
  5086. /**
  5087. * Adds tags to an object
  5088. * @param obj defines the object to use
  5089. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5090. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5091. */
  5092. static AddTagsTo(obj: any, tagsString: string): void;
  5093. /**
  5094. * @hidden
  5095. */ private static _AddTagTo(obj: any, tag: string): void;
  5096. /**
  5097. * Removes specific tags from a specific object
  5098. * @param obj defines the object to use
  5099. * @param tagsString defines the tags to remove
  5100. */
  5101. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5102. /**
  5103. * @hidden
  5104. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5105. /**
  5106. * Defines if tags hosted on an object match a given query
  5107. * @param obj defines the object to use
  5108. * @param tagsQuery defines the tag query
  5109. * @returns a boolean
  5110. */
  5111. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5112. }
  5113. }
  5114. declare module BABYLON {
  5115. /**
  5116. * Manages the defines for the Material
  5117. */
  5118. export class MaterialDefines {
  5119. private _keys;
  5120. private _isDirty;
  5121. /** @hidden */ renderId: number;
  5122. /** @hidden */ areLightsDirty: boolean;
  5123. /** @hidden */ areAttributesDirty: boolean;
  5124. /** @hidden */ areTexturesDirty: boolean;
  5125. /** @hidden */ areFresnelDirty: boolean;
  5126. /** @hidden */ areMiscDirty: boolean;
  5127. /** @hidden */ areImageProcessingDirty: boolean;
  5128. /** @hidden */ normals: boolean;
  5129. /** @hidden */ uvs: boolean;
  5130. /** @hidden */ needNormals: boolean;
  5131. /** @hidden */ needUVs: boolean;
  5132. /**
  5133. * Specifies if the material needs to be re-calculated
  5134. */
  5135. readonly isDirty: boolean;
  5136. /**
  5137. * Marks the material to indicate that it has been re-calculated
  5138. */
  5139. markAsProcessed(): void;
  5140. /**
  5141. * Marks the material to indicate that it needs to be re-calculated
  5142. */
  5143. markAsUnprocessed(): void;
  5144. /**
  5145. * Marks the material to indicate all of its defines need to be re-calculated
  5146. */
  5147. markAllAsDirty(): void;
  5148. /**
  5149. * Marks the material to indicate that image processing needs to be re-calculated
  5150. */
  5151. markAsImageProcessingDirty(): void;
  5152. /**
  5153. * Marks the material to indicate the lights need to be re-calculated
  5154. */
  5155. markAsLightDirty(): void;
  5156. /**
  5157. * Marks the attribute state as changed
  5158. */
  5159. markAsAttributesDirty(): void;
  5160. /**
  5161. * Marks the texture state as changed
  5162. */
  5163. markAsTexturesDirty(): void;
  5164. /**
  5165. * Marks the fresnel state as changed
  5166. */
  5167. markAsFresnelDirty(): void;
  5168. /**
  5169. * Marks the misc state as changed
  5170. */
  5171. markAsMiscDirty(): void;
  5172. /**
  5173. * Rebuilds the material defines
  5174. */
  5175. rebuild(): void;
  5176. /**
  5177. * Specifies if two material defines are equal
  5178. * @param other - A material define instance to compare to
  5179. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5180. */
  5181. isEqual(other: MaterialDefines): boolean;
  5182. /**
  5183. * Clones this instance's defines to another instance
  5184. * @param other - material defines to clone values to
  5185. */
  5186. cloneTo(other: MaterialDefines): void;
  5187. /**
  5188. * Resets the material define values
  5189. */
  5190. reset(): void;
  5191. /**
  5192. * Converts the material define values to a string
  5193. * @returns - String of material define information
  5194. */
  5195. toString(): string;
  5196. }
  5197. }
  5198. declare module BABYLON {
  5199. /**
  5200. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5201. */
  5202. export class PerformanceMonitor {
  5203. private _enabled;
  5204. private _rollingFrameTime;
  5205. private _lastFrameTimeMs;
  5206. /**
  5207. * constructor
  5208. * @param frameSampleSize The number of samples required to saturate the sliding window
  5209. */
  5210. constructor(frameSampleSize?: number);
  5211. /**
  5212. * Samples current frame
  5213. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5214. */
  5215. sampleFrame(timeMs?: number): void;
  5216. /**
  5217. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5218. */
  5219. readonly averageFrameTime: number;
  5220. /**
  5221. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5222. */
  5223. readonly averageFrameTimeVariance: number;
  5224. /**
  5225. * Returns the frame time of the most recent frame
  5226. */
  5227. readonly instantaneousFrameTime: number;
  5228. /**
  5229. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5230. */
  5231. readonly averageFPS: number;
  5232. /**
  5233. * Returns the average framerate in frames per second using the most recent frame time
  5234. */
  5235. readonly instantaneousFPS: number;
  5236. /**
  5237. * Returns true if enough samples have been taken to completely fill the sliding window
  5238. */
  5239. readonly isSaturated: boolean;
  5240. /**
  5241. * Enables contributions to the sliding window sample set
  5242. */
  5243. enable(): void;
  5244. /**
  5245. * Disables contributions to the sliding window sample set
  5246. * Samples will not be interpolated over the disabled period
  5247. */
  5248. disable(): void;
  5249. /**
  5250. * Returns true if sampling is enabled
  5251. */
  5252. readonly isEnabled: boolean;
  5253. /**
  5254. * Resets performance monitor
  5255. */
  5256. reset(): void;
  5257. }
  5258. /**
  5259. * RollingAverage
  5260. *
  5261. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5262. */
  5263. export class RollingAverage {
  5264. /**
  5265. * Current average
  5266. */
  5267. average: number;
  5268. /**
  5269. * Current variance
  5270. */
  5271. variance: number;
  5272. protected _samples: Array<number>;
  5273. protected _sampleCount: number;
  5274. protected _pos: number;
  5275. protected _m2: number;
  5276. /**
  5277. * constructor
  5278. * @param length The number of samples required to saturate the sliding window
  5279. */
  5280. constructor(length: number);
  5281. /**
  5282. * Adds a sample to the sample set
  5283. * @param v The sample value
  5284. */
  5285. add(v: number): void;
  5286. /**
  5287. * Returns previously added values or null if outside of history or outside the sliding window domain
  5288. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5289. * @return Value previously recorded with add() or null if outside of range
  5290. */
  5291. history(i: number): number;
  5292. /**
  5293. * Returns true if enough samples have been taken to completely fill the sliding window
  5294. * @return true if sample-set saturated
  5295. */
  5296. isSaturated(): boolean;
  5297. /**
  5298. * Resets the rolling average (equivalent to 0 samples taken so far)
  5299. */
  5300. reset(): void;
  5301. /**
  5302. * Wraps a value around the sample range boundaries
  5303. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5304. * @return Wrapped position in sample range
  5305. */
  5306. protected _wrapPosition(i: number): number;
  5307. }
  5308. }
  5309. declare module BABYLON {
  5310. /**
  5311. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5312. * The underlying implementation relies on an associative array to ensure the best performances.
  5313. * The value can be anything including 'null' but except 'undefined'
  5314. */
  5315. export class StringDictionary<T> {
  5316. /**
  5317. * This will clear this dictionary and copy the content from the 'source' one.
  5318. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5319. * @param source the dictionary to take the content from and copy to this dictionary
  5320. */
  5321. copyFrom(source: StringDictionary<T>): void;
  5322. /**
  5323. * Get a value based from its key
  5324. * @param key the given key to get the matching value from
  5325. * @return the value if found, otherwise undefined is returned
  5326. */
  5327. get(key: string): T | undefined;
  5328. /**
  5329. * Get a value from its key or add it if it doesn't exist.
  5330. * This method will ensure you that a given key/data will be present in the dictionary.
  5331. * @param key the given key to get the matching value from
  5332. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5333. * The factory will only be invoked if there's no data for the given key.
  5334. * @return the value corresponding to the key.
  5335. */
  5336. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5337. /**
  5338. * Get a value from its key if present in the dictionary otherwise add it
  5339. * @param key the key to get the value from
  5340. * @param val if there's no such key/value pair in the dictionary add it with this value
  5341. * @return the value corresponding to the key
  5342. */
  5343. getOrAdd(key: string, val: T): T;
  5344. /**
  5345. * Check if there's a given key in the dictionary
  5346. * @param key the key to check for
  5347. * @return true if the key is present, false otherwise
  5348. */
  5349. contains(key: string): boolean;
  5350. /**
  5351. * Add a new key and its corresponding value
  5352. * @param key the key to add
  5353. * @param value the value corresponding to the key
  5354. * @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
  5355. */
  5356. add(key: string, value: T): boolean;
  5357. /**
  5358. * Update a specific value associated to a key
  5359. * @param key defines the key to use
  5360. * @param value defines the value to store
  5361. * @returns true if the value was updated (or false if the key was not found)
  5362. */
  5363. set(key: string, value: T): boolean;
  5364. /**
  5365. * Get the element of the given key and remove it from the dictionary
  5366. * @param key defines the key to search
  5367. * @returns the value associated with the key or null if not found
  5368. */
  5369. getAndRemove(key: string): Nullable<T>;
  5370. /**
  5371. * Remove a key/value from the dictionary.
  5372. * @param key the key to remove
  5373. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5374. */
  5375. remove(key: string): boolean;
  5376. /**
  5377. * Clear the whole content of the dictionary
  5378. */
  5379. clear(): void;
  5380. /**
  5381. * Gets the current count
  5382. */
  5383. readonly count: number;
  5384. /**
  5385. * Execute a callback on each key/val of the dictionary.
  5386. * Note that you can remove any element in this dictionary in the callback implementation
  5387. * @param callback the callback to execute on a given key/value pair
  5388. */
  5389. forEach(callback: (key: string, val: T) => void): void;
  5390. /**
  5391. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5392. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5393. * Note that you can remove any element in this dictionary in the callback implementation
  5394. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5395. * @returns the first item
  5396. */
  5397. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5398. private _count;
  5399. private _data;
  5400. }
  5401. }
  5402. declare module BABYLON {
  5403. /**
  5404. * Helper class that provides a small promise polyfill
  5405. */
  5406. export class PromisePolyfill {
  5407. /**
  5408. * Static function used to check if the polyfill is required
  5409. * If this is the case then the function will inject the polyfill to window.Promise
  5410. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5411. */
  5412. static Apply(force?: boolean): void;
  5413. }
  5414. }
  5415. declare module BABYLON {
  5416. /**
  5417. * Class used to store data that will be store in GPU memory
  5418. */
  5419. export class Buffer {
  5420. private _engine;
  5421. private _buffer;
  5422. /** @hidden */ data: Nullable<DataArray>;
  5423. private _updatable;
  5424. private _instanced;
  5425. /**
  5426. * Gets the byte stride.
  5427. */
  5428. readonly byteStride: number;
  5429. /**
  5430. * Constructor
  5431. * @param engine the engine
  5432. * @param data the data to use for this buffer
  5433. * @param updatable whether the data is updatable
  5434. * @param stride the stride (optional)
  5435. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5436. * @param instanced whether the buffer is instanced (optional)
  5437. * @param useBytes set to true if the stride in in bytes (optional)
  5438. */
  5439. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5440. /**
  5441. * Create a new VertexBuffer based on the current buffer
  5442. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5443. * @param offset defines offset in the buffer (0 by default)
  5444. * @param size defines the size in floats of attributes (position is 3 for instance)
  5445. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5446. * @param instanced defines if the vertex buffer contains indexed data
  5447. * @param useBytes defines if the offset and stride are in bytes
  5448. * @returns the new vertex buffer
  5449. */
  5450. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5451. /**
  5452. * Gets a boolean indicating if the Buffer is updatable?
  5453. * @returns true if the buffer is updatable
  5454. */
  5455. isUpdatable(): boolean;
  5456. /**
  5457. * Gets current buffer's data
  5458. * @returns a DataArray or null
  5459. */
  5460. getData(): Nullable<DataArray>;
  5461. /**
  5462. * Gets underlying native buffer
  5463. * @returns underlying native buffer
  5464. */
  5465. getBuffer(): Nullable<WebGLBuffer>;
  5466. /**
  5467. * Gets the stride in float32 units (i.e. byte stride / 4).
  5468. * May not be an integer if the byte stride is not divisible by 4.
  5469. * DEPRECATED. Use byteStride instead.
  5470. * @returns the stride in float32 units
  5471. */
  5472. getStrideSize(): number;
  5473. /**
  5474. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5475. * @param data defines the data to store
  5476. */
  5477. create(data?: Nullable<DataArray>): void;
  5478. /** @hidden */ rebuild(): void;
  5479. /**
  5480. * Update current buffer data
  5481. * @param data defines the data to store
  5482. */
  5483. update(data: DataArray): void;
  5484. /**
  5485. * Updates the data directly.
  5486. * @param data the new data
  5487. * @param offset the new offset
  5488. * @param vertexCount the vertex count (optional)
  5489. * @param useBytes set to true if the offset is in bytes
  5490. */
  5491. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5492. /**
  5493. * Release all resources
  5494. */
  5495. dispose(): void;
  5496. }
  5497. /**
  5498. * Specialized buffer used to store vertex data
  5499. */
  5500. export class VertexBuffer {
  5501. /** @hidden */ buffer: Buffer;
  5502. private _kind;
  5503. private _size;
  5504. private _ownsBuffer;
  5505. private _instanced;
  5506. private _instanceDivisor;
  5507. /**
  5508. * The byte type.
  5509. */
  5510. static readonly BYTE: number;
  5511. /**
  5512. * The unsigned byte type.
  5513. */
  5514. static readonly UNSIGNED_BYTE: number;
  5515. /**
  5516. * The short type.
  5517. */
  5518. static readonly SHORT: number;
  5519. /**
  5520. * The unsigned short type.
  5521. */
  5522. static readonly UNSIGNED_SHORT: number;
  5523. /**
  5524. * The integer type.
  5525. */
  5526. static readonly INT: number;
  5527. /**
  5528. * The unsigned integer type.
  5529. */
  5530. static readonly UNSIGNED_INT: number;
  5531. /**
  5532. * The float type.
  5533. */
  5534. static readonly FLOAT: number;
  5535. /**
  5536. * Gets or sets the instance divisor when in instanced mode
  5537. */
  5538. instanceDivisor: number;
  5539. /**
  5540. * Gets the byte stride.
  5541. */
  5542. readonly byteStride: number;
  5543. /**
  5544. * Gets the byte offset.
  5545. */
  5546. readonly byteOffset: number;
  5547. /**
  5548. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5549. */
  5550. readonly normalized: boolean;
  5551. /**
  5552. * Gets the data type of each component in the array.
  5553. */
  5554. readonly type: number;
  5555. /**
  5556. * Constructor
  5557. * @param engine the engine
  5558. * @param data the data to use for this vertex buffer
  5559. * @param kind the vertex buffer kind
  5560. * @param updatable whether the data is updatable
  5561. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5562. * @param stride the stride (optional)
  5563. * @param instanced whether the buffer is instanced (optional)
  5564. * @param offset the offset of the data (optional)
  5565. * @param size the number of components (optional)
  5566. * @param type the type of the component (optional)
  5567. * @param normalized whether the data contains normalized data (optional)
  5568. * @param useBytes set to true if stride and offset are in bytes (optional)
  5569. */
  5570. 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);
  5571. /** @hidden */ rebuild(): void;
  5572. /**
  5573. * Returns the kind of the VertexBuffer (string)
  5574. * @returns a string
  5575. */
  5576. getKind(): string;
  5577. /**
  5578. * Gets a boolean indicating if the VertexBuffer is updatable?
  5579. * @returns true if the buffer is updatable
  5580. */
  5581. isUpdatable(): boolean;
  5582. /**
  5583. * Gets current buffer's data
  5584. * @returns a DataArray or null
  5585. */
  5586. getData(): Nullable<DataArray>;
  5587. /**
  5588. * Gets underlying native buffer
  5589. * @returns underlying native buffer
  5590. */
  5591. getBuffer(): Nullable<WebGLBuffer>;
  5592. /**
  5593. * Gets the stride in float32 units (i.e. byte stride / 4).
  5594. * May not be an integer if the byte stride is not divisible by 4.
  5595. * DEPRECATED. Use byteStride instead.
  5596. * @returns the stride in float32 units
  5597. */
  5598. getStrideSize(): number;
  5599. /**
  5600. * Returns the offset as a multiple of the type byte length.
  5601. * DEPRECATED. Use byteOffset instead.
  5602. * @returns the offset in bytes
  5603. */
  5604. getOffset(): number;
  5605. /**
  5606. * Returns the number of components per vertex attribute (integer)
  5607. * @returns the size in float
  5608. */
  5609. getSize(): number;
  5610. /**
  5611. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5612. * @returns true if this buffer is instanced
  5613. */
  5614. getIsInstanced(): boolean;
  5615. /**
  5616. * Returns the instancing divisor, zero for non-instanced (integer).
  5617. * @returns a number
  5618. */
  5619. getInstanceDivisor(): number;
  5620. /**
  5621. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5622. * @param data defines the data to store
  5623. */
  5624. create(data?: DataArray): void;
  5625. /**
  5626. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5627. * This function will create a new buffer if the current one is not updatable
  5628. * @param data defines the data to store
  5629. */
  5630. update(data: DataArray): void;
  5631. /**
  5632. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5633. * Returns the directly updated WebGLBuffer.
  5634. * @param data the new data
  5635. * @param offset the new offset
  5636. * @param useBytes set to true if the offset is in bytes
  5637. */
  5638. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5639. /**
  5640. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5641. */
  5642. dispose(): void;
  5643. /**
  5644. * Enumerates each value of this vertex buffer as numbers.
  5645. * @param count the number of values to enumerate
  5646. * @param callback the callback function called for each value
  5647. */
  5648. forEach(count: number, callback: (value: number, index: number) => void): void;
  5649. /**
  5650. * Positions
  5651. */
  5652. static readonly PositionKind: string;
  5653. /**
  5654. * Normals
  5655. */
  5656. static readonly NormalKind: string;
  5657. /**
  5658. * Tangents
  5659. */
  5660. static readonly TangentKind: string;
  5661. /**
  5662. * Texture coordinates
  5663. */
  5664. static readonly UVKind: string;
  5665. /**
  5666. * Texture coordinates 2
  5667. */
  5668. static readonly UV2Kind: string;
  5669. /**
  5670. * Texture coordinates 3
  5671. */
  5672. static readonly UV3Kind: string;
  5673. /**
  5674. * Texture coordinates 4
  5675. */
  5676. static readonly UV4Kind: string;
  5677. /**
  5678. * Texture coordinates 5
  5679. */
  5680. static readonly UV5Kind: string;
  5681. /**
  5682. * Texture coordinates 6
  5683. */
  5684. static readonly UV6Kind: string;
  5685. /**
  5686. * Colors
  5687. */
  5688. static readonly ColorKind: string;
  5689. /**
  5690. * Matrix indices (for bones)
  5691. */
  5692. static readonly MatricesIndicesKind: string;
  5693. /**
  5694. * Matrix weights (for bones)
  5695. */
  5696. static readonly MatricesWeightsKind: string;
  5697. /**
  5698. * Additional matrix indices (for bones)
  5699. */
  5700. static readonly MatricesIndicesExtraKind: string;
  5701. /**
  5702. * Additional matrix weights (for bones)
  5703. */
  5704. static readonly MatricesWeightsExtraKind: string;
  5705. /**
  5706. * Deduces the stride given a kind.
  5707. * @param kind The kind string to deduce
  5708. * @returns The deduced stride
  5709. */
  5710. static DeduceStride(kind: string): number;
  5711. /**
  5712. * Gets the byte length of the given type.
  5713. * @param type the type
  5714. * @returns the number of bytes
  5715. */
  5716. static GetTypeByteLength(type: number): number;
  5717. /**
  5718. * Enumerates each value of the given parameters as numbers.
  5719. * @param data the data to enumerate
  5720. * @param byteOffset the byte offset of the data
  5721. * @param byteStride the byte stride of the data
  5722. * @param componentCount the number of components per element
  5723. * @param componentType the type of the component
  5724. * @param count the total number of components
  5725. * @param normalized whether the data is normalized
  5726. * @param callback the callback function called for each value
  5727. */
  5728. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5729. private static _GetFloatValue;
  5730. }
  5731. }
  5732. declare module BABYLON {
  5733. /**
  5734. * Class representing spherical polynomial coefficients to the 3rd degree
  5735. */
  5736. export class SphericalPolynomial {
  5737. /**
  5738. * The x coefficients of the spherical polynomial
  5739. */
  5740. x: Vector3;
  5741. /**
  5742. * The y coefficients of the spherical polynomial
  5743. */
  5744. y: Vector3;
  5745. /**
  5746. * The z coefficients of the spherical polynomial
  5747. */
  5748. z: Vector3;
  5749. /**
  5750. * The xx coefficients of the spherical polynomial
  5751. */
  5752. xx: Vector3;
  5753. /**
  5754. * The yy coefficients of the spherical polynomial
  5755. */
  5756. yy: Vector3;
  5757. /**
  5758. * The zz coefficients of the spherical polynomial
  5759. */
  5760. zz: Vector3;
  5761. /**
  5762. * The xy coefficients of the spherical polynomial
  5763. */
  5764. xy: Vector3;
  5765. /**
  5766. * The yz coefficients of the spherical polynomial
  5767. */
  5768. yz: Vector3;
  5769. /**
  5770. * The zx coefficients of the spherical polynomial
  5771. */
  5772. zx: Vector3;
  5773. /**
  5774. * Adds an ambient color to the spherical polynomial
  5775. * @param color the color to add
  5776. */
  5777. addAmbient(color: Color3): void;
  5778. /**
  5779. * Scales the spherical polynomial by the given amount
  5780. * @param scale the amount to scale
  5781. */
  5782. scale(scale: number): void;
  5783. /**
  5784. * Gets the spherical polynomial from harmonics
  5785. * @param harmonics the spherical harmonics
  5786. * @returns the spherical polynomial
  5787. */
  5788. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5789. /**
  5790. * Constructs a spherical polynomial from an array.
  5791. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5792. * @returns the spherical polynomial
  5793. */
  5794. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5795. }
  5796. /**
  5797. * Class representing spherical harmonics coefficients to the 3rd degree
  5798. */
  5799. export class SphericalHarmonics {
  5800. /**
  5801. * The l0,0 coefficients of the spherical harmonics
  5802. */
  5803. l00: Vector3;
  5804. /**
  5805. * The l1,-1 coefficients of the spherical harmonics
  5806. */
  5807. l1_1: Vector3;
  5808. /**
  5809. * The l1,0 coefficients of the spherical harmonics
  5810. */
  5811. l10: Vector3;
  5812. /**
  5813. * The l1,1 coefficients of the spherical harmonics
  5814. */
  5815. l11: Vector3;
  5816. /**
  5817. * The l2,-2 coefficients of the spherical harmonics
  5818. */
  5819. l2_2: Vector3;
  5820. /**
  5821. * The l2,-1 coefficients of the spherical harmonics
  5822. */
  5823. l2_1: Vector3;
  5824. /**
  5825. * The l2,0 coefficients of the spherical harmonics
  5826. */
  5827. l20: Vector3;
  5828. /**
  5829. * The l2,1 coefficients of the spherical harmonics
  5830. */
  5831. l21: Vector3;
  5832. /**
  5833. * The l2,2 coefficients of the spherical harmonics
  5834. */
  5835. lL22: Vector3;
  5836. /**
  5837. * Adds a light to the spherical harmonics
  5838. * @param direction the direction of the light
  5839. * @param color the color of the light
  5840. * @param deltaSolidAngle the delta solid angle of the light
  5841. */
  5842. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5843. /**
  5844. * Scales the spherical harmonics by the given amount
  5845. * @param scale the amount to scale
  5846. */
  5847. scale(scale: number): void;
  5848. /**
  5849. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5850. *
  5851. * ```
  5852. * E_lm = A_l * L_lm
  5853. * ```
  5854. *
  5855. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5856. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5857. * the scaling factors are given in equation 9.
  5858. */
  5859. convertIncidentRadianceToIrradiance(): void;
  5860. /**
  5861. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5862. *
  5863. * ```
  5864. * L = (1/pi) * E * rho
  5865. * ```
  5866. *
  5867. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5868. */
  5869. convertIrradianceToLambertianRadiance(): void;
  5870. /**
  5871. * Gets the spherical harmonics from polynomial
  5872. * @param polynomial the spherical polynomial
  5873. * @returns the spherical harmonics
  5874. */
  5875. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5876. /**
  5877. * Constructs a spherical harmonics from an array.
  5878. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5879. * @returns the spherical harmonics
  5880. */
  5881. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5882. }
  5883. }
  5884. declare module BABYLON {
  5885. /**
  5886. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5887. */
  5888. export interface CubeMapInfo {
  5889. /**
  5890. * The pixel array for the front face.
  5891. * This is stored in format, left to right, up to down format.
  5892. */
  5893. front: Nullable<ArrayBufferView>;
  5894. /**
  5895. * The pixel array for the back face.
  5896. * This is stored in format, left to right, up to down format.
  5897. */
  5898. back: Nullable<ArrayBufferView>;
  5899. /**
  5900. * The pixel array for the left face.
  5901. * This is stored in format, left to right, up to down format.
  5902. */
  5903. left: Nullable<ArrayBufferView>;
  5904. /**
  5905. * The pixel array for the right face.
  5906. * This is stored in format, left to right, up to down format.
  5907. */
  5908. right: Nullable<ArrayBufferView>;
  5909. /**
  5910. * The pixel array for the up face.
  5911. * This is stored in format, left to right, up to down format.
  5912. */
  5913. up: Nullable<ArrayBufferView>;
  5914. /**
  5915. * The pixel array for the down face.
  5916. * This is stored in format, left to right, up to down format.
  5917. */
  5918. down: Nullable<ArrayBufferView>;
  5919. /**
  5920. * The size of the cubemap stored.
  5921. *
  5922. * Each faces will be size * size pixels.
  5923. */
  5924. size: number;
  5925. /**
  5926. * The format of the texture.
  5927. *
  5928. * RGBA, RGB.
  5929. */
  5930. format: number;
  5931. /**
  5932. * The type of the texture data.
  5933. *
  5934. * UNSIGNED_INT, FLOAT.
  5935. */
  5936. type: number;
  5937. /**
  5938. * Specifies whether the texture is in gamma space.
  5939. */
  5940. gammaSpace: boolean;
  5941. }
  5942. /**
  5943. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5944. */
  5945. export class PanoramaToCubeMapTools {
  5946. private static FACE_FRONT;
  5947. private static FACE_BACK;
  5948. private static FACE_RIGHT;
  5949. private static FACE_LEFT;
  5950. private static FACE_DOWN;
  5951. private static FACE_UP;
  5952. /**
  5953. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5954. *
  5955. * @param float32Array The source data.
  5956. * @param inputWidth The width of the input panorama.
  5957. * @param inputHeight The height of the input panorama.
  5958. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5959. * @return The cubemap data
  5960. */
  5961. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5962. private static CreateCubemapTexture;
  5963. private static CalcProjectionSpherical;
  5964. }
  5965. }
  5966. declare module BABYLON {
  5967. /**
  5968. * Helper class dealing with the extraction of spherical polynomial dataArray
  5969. * from a cube map.
  5970. */
  5971. export class CubeMapToSphericalPolynomialTools {
  5972. private static FileFaces;
  5973. /**
  5974. * Converts a texture to the according Spherical Polynomial data.
  5975. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5976. *
  5977. * @param texture The texture to extract the information from.
  5978. * @return The Spherical Polynomial data.
  5979. */
  5980. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5981. /**
  5982. * Converts a cubemap to the according Spherical Polynomial data.
  5983. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5984. *
  5985. * @param cubeInfo The Cube map to extract the information from.
  5986. * @return The Spherical Polynomial data.
  5987. */
  5988. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5989. }
  5990. }
  5991. declare module BABYLON {
  5992. /**
  5993. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5994. * during the life time of the application.
  5995. */
  5996. export class EngineStore {
  5997. /** Gets the list of created engines */
  5998. static Instances: Engine[];
  5999. /**
  6000. * Gets the latest created engine
  6001. */
  6002. static readonly LastCreatedEngine: Nullable<Engine>;
  6003. /**
  6004. * Gets the latest created scene
  6005. */
  6006. static readonly LastCreatedScene: Nullable<Scene>;
  6007. }
  6008. }
  6009. declare module BABYLON {
  6010. /**
  6011. * Define options used to create a render target texture
  6012. */
  6013. export class RenderTargetCreationOptions {
  6014. /**
  6015. * Specifies is mipmaps must be generated
  6016. */
  6017. generateMipMaps?: boolean;
  6018. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6019. generateDepthBuffer?: boolean;
  6020. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6021. generateStencilBuffer?: boolean;
  6022. /** Defines texture type (int by default) */
  6023. type?: number;
  6024. /** Defines sampling mode (trilinear by default) */
  6025. samplingMode?: number;
  6026. /** Defines format (RGBA by default) */
  6027. format?: number;
  6028. }
  6029. }
  6030. declare module BABYLON {
  6031. /**
  6032. * @hidden
  6033. **/
  6034. export class _AlphaState {
  6035. private _isAlphaBlendDirty;
  6036. private _isBlendFunctionParametersDirty;
  6037. private _isBlendEquationParametersDirty;
  6038. private _isBlendConstantsDirty;
  6039. private _alphaBlend;
  6040. private _blendFunctionParameters;
  6041. private _blendEquationParameters;
  6042. private _blendConstants;
  6043. /**
  6044. * Initializes the state.
  6045. */
  6046. constructor();
  6047. readonly isDirty: boolean;
  6048. alphaBlend: boolean;
  6049. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6050. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6051. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6052. reset(): void;
  6053. apply(gl: WebGLRenderingContext): void;
  6054. }
  6055. }
  6056. declare module BABYLON {
  6057. /**
  6058. * @hidden
  6059. **/
  6060. export class _DepthCullingState {
  6061. private _isDepthTestDirty;
  6062. private _isDepthMaskDirty;
  6063. private _isDepthFuncDirty;
  6064. private _isCullFaceDirty;
  6065. private _isCullDirty;
  6066. private _isZOffsetDirty;
  6067. private _isFrontFaceDirty;
  6068. private _depthTest;
  6069. private _depthMask;
  6070. private _depthFunc;
  6071. private _cull;
  6072. private _cullFace;
  6073. private _zOffset;
  6074. private _frontFace;
  6075. /**
  6076. * Initializes the state.
  6077. */
  6078. constructor();
  6079. readonly isDirty: boolean;
  6080. zOffset: number;
  6081. cullFace: Nullable<number>;
  6082. cull: Nullable<boolean>;
  6083. depthFunc: Nullable<number>;
  6084. depthMask: boolean;
  6085. depthTest: boolean;
  6086. frontFace: Nullable<number>;
  6087. reset(): void;
  6088. apply(gl: WebGLRenderingContext): void;
  6089. }
  6090. }
  6091. declare module BABYLON {
  6092. /**
  6093. * @hidden
  6094. **/
  6095. export class _StencilState {
  6096. /** 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 */
  6097. static readonly ALWAYS: number;
  6098. /** Passed to stencilOperation to specify that stencil value must be kept */
  6099. static readonly KEEP: number;
  6100. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6101. static readonly REPLACE: number;
  6102. private _isStencilTestDirty;
  6103. private _isStencilMaskDirty;
  6104. private _isStencilFuncDirty;
  6105. private _isStencilOpDirty;
  6106. private _stencilTest;
  6107. private _stencilMask;
  6108. private _stencilFunc;
  6109. private _stencilFuncRef;
  6110. private _stencilFuncMask;
  6111. private _stencilOpStencilFail;
  6112. private _stencilOpDepthFail;
  6113. private _stencilOpStencilDepthPass;
  6114. readonly isDirty: boolean;
  6115. stencilFunc: number;
  6116. stencilFuncRef: number;
  6117. stencilFuncMask: number;
  6118. stencilOpStencilFail: number;
  6119. stencilOpDepthFail: number;
  6120. stencilOpStencilDepthPass: number;
  6121. stencilMask: number;
  6122. stencilTest: boolean;
  6123. constructor();
  6124. reset(): void;
  6125. apply(gl: WebGLRenderingContext): void;
  6126. }
  6127. }
  6128. declare module BABYLON {
  6129. /**
  6130. * @hidden
  6131. **/
  6132. export class _TimeToken { startTimeQuery: Nullable<WebGLQuery>; endTimeQuery: Nullable<WebGLQuery>; timeElapsedQuery: Nullable<WebGLQuery>; timeElapsedQueryEnded: boolean;
  6133. }
  6134. }
  6135. declare module BABYLON {
  6136. /**
  6137. * Internal interface used to track InternalTexture already bound to the GL context
  6138. */
  6139. export interface IInternalTextureTracker {
  6140. /**
  6141. * Gets or set the previous tracker in the list
  6142. */
  6143. previous: Nullable<IInternalTextureTracker>;
  6144. /**
  6145. * Gets or set the next tracker in the list
  6146. */
  6147. next: Nullable<IInternalTextureTracker>;
  6148. }
  6149. /**
  6150. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6151. */
  6152. export class DummyInternalTextureTracker {
  6153. /**
  6154. * Gets or set the previous tracker in the list
  6155. */
  6156. previous: Nullable<IInternalTextureTracker>;
  6157. /**
  6158. * Gets or set the next tracker in the list
  6159. */
  6160. next: Nullable<IInternalTextureTracker>;
  6161. }
  6162. }
  6163. declare module BABYLON {
  6164. /**
  6165. * Class used to store data associated with WebGL texture data for the engine
  6166. * This class should not be used directly
  6167. */
  6168. export class InternalTexture implements IInternalTextureTracker {
  6169. /** hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6170. /**
  6171. * The source of the texture data is unknown
  6172. */
  6173. static DATASOURCE_UNKNOWN: number;
  6174. /**
  6175. * Texture data comes from an URL
  6176. */
  6177. static DATASOURCE_URL: number;
  6178. /**
  6179. * Texture data is only used for temporary storage
  6180. */
  6181. static DATASOURCE_TEMP: number;
  6182. /**
  6183. * Texture data comes from raw data (ArrayBuffer)
  6184. */
  6185. static DATASOURCE_RAW: number;
  6186. /**
  6187. * Texture content is dynamic (video or dynamic texture)
  6188. */
  6189. static DATASOURCE_DYNAMIC: number;
  6190. /**
  6191. * Texture content is generated by rendering to it
  6192. */
  6193. static DATASOURCE_RENDERTARGET: number;
  6194. /**
  6195. * Texture content is part of a multi render target process
  6196. */
  6197. static DATASOURCE_MULTIRENDERTARGET: number;
  6198. /**
  6199. * Texture data comes from a cube data file
  6200. */
  6201. static DATASOURCE_CUBE: number;
  6202. /**
  6203. * Texture data comes from a raw cube data
  6204. */
  6205. static DATASOURCE_CUBERAW: number;
  6206. /**
  6207. * Texture data come from a prefiltered cube data file
  6208. */
  6209. static DATASOURCE_CUBEPREFILTERED: number;
  6210. /**
  6211. * Texture content is raw 3D data
  6212. */
  6213. static DATASOURCE_RAW3D: number;
  6214. /**
  6215. * Texture content is a depth texture
  6216. */
  6217. static DATASOURCE_DEPTHTEXTURE: number;
  6218. /**
  6219. * Texture data comes from a raw cube data encoded with RGBD
  6220. */
  6221. static DATASOURCE_CUBERAW_RGBD: number;
  6222. /**
  6223. * Defines if the texture is ready
  6224. */
  6225. isReady: boolean;
  6226. /**
  6227. * Defines if the texture is a cube texture
  6228. */
  6229. isCube: boolean;
  6230. /**
  6231. * Defines if the texture contains 3D data
  6232. */
  6233. is3D: boolean;
  6234. /**
  6235. * Defines if the texture contains multiview data
  6236. */
  6237. isMultiview: boolean;
  6238. /**
  6239. * Gets the URL used to load this texture
  6240. */
  6241. url: string;
  6242. /**
  6243. * Gets the sampling mode of the texture
  6244. */
  6245. samplingMode: number;
  6246. /**
  6247. * Gets a boolean indicating if the texture needs mipmaps generation
  6248. */
  6249. generateMipMaps: boolean;
  6250. /**
  6251. * Gets the number of samples used by the texture (WebGL2+ only)
  6252. */
  6253. samples: number;
  6254. /**
  6255. * Gets the type of the texture (int, float...)
  6256. */
  6257. type: number;
  6258. /**
  6259. * Gets the format of the texture (RGB, RGBA...)
  6260. */
  6261. format: number;
  6262. /**
  6263. * Observable called when the texture is loaded
  6264. */
  6265. onLoadedObservable: Observable<InternalTexture>;
  6266. /**
  6267. * Gets the width of the texture
  6268. */
  6269. width: number;
  6270. /**
  6271. * Gets the height of the texture
  6272. */
  6273. height: number;
  6274. /**
  6275. * Gets the depth of the texture
  6276. */
  6277. depth: number;
  6278. /**
  6279. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6280. */
  6281. baseWidth: number;
  6282. /**
  6283. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6284. */
  6285. baseHeight: number;
  6286. /**
  6287. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6288. */
  6289. baseDepth: number;
  6290. /**
  6291. * Gets a boolean indicating if the texture is inverted on Y axis
  6292. */
  6293. invertY: boolean;
  6294. /**
  6295. * Gets or set the previous tracker in the list
  6296. */
  6297. previous: Nullable<IInternalTextureTracker>;
  6298. /**
  6299. * Gets or set the next tracker in the list
  6300. */
  6301. next: Nullable<IInternalTextureTracker>;
  6302. /** @hidden */ invertVScale: boolean;
  6303. /** @hidden */ initialSlot: number;
  6304. /** @hidden */ designatedSlot: number;
  6305. /** @hidden */ dataSource: number;
  6306. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6307. /** @hidden */ bufferView: Nullable<ArrayBufferView>;
  6308. /** @hidden */ bufferViewArray: Nullable<ArrayBufferView[]>;
  6309. /** @hidden */ bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6310. /** @hidden */ size: number;
  6311. /** @hidden */ extension: string;
  6312. /** @hidden */ files: Nullable<string[]>;
  6313. /** @hidden */ workingCanvas: HTMLCanvasElement;
  6314. /** @hidden */ workingContext: CanvasRenderingContext2D;
  6315. /** @hidden */ framebuffer: Nullable<WebGLFramebuffer>;
  6316. /** @hidden */ depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6317. /** @hidden */ MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6318. /** @hidden */ MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6319. /** @hidden */ attachments: Nullable<number[]>;
  6320. /** @hidden */ cachedCoordinatesMode: Nullable<number>;
  6321. /** @hidden */ cachedWrapU: Nullable<number>;
  6322. /** @hidden */ cachedWrapV: Nullable<number>;
  6323. /** @hidden */ cachedWrapR: Nullable<number>;
  6324. /** @hidden */ cachedAnisotropicFilteringLevel: Nullable<number>;
  6325. /** @hidden */ isDisabled: boolean;
  6326. /** @hidden */ compression: Nullable<string>;
  6327. /** @hidden */ generateStencilBuffer: boolean;
  6328. /** @hidden */ generateDepthBuffer: boolean;
  6329. /** @hidden */ comparisonFunction: number;
  6330. /** @hidden */ sphericalPolynomial: Nullable<SphericalPolynomial>;
  6331. /** @hidden */ lodGenerationScale: number;
  6332. /** @hidden */ lodGenerationOffset: number;
  6333. /** @hidden */ colorTextureArray: Nullable<WebGLTexture>;
  6334. /** @hidden */ depthStencilTextureArray: Nullable<WebGLTexture>;
  6335. /** @hidden */ lodTextureHigh: BaseTexture;
  6336. /** @hidden */ lodTextureMid: BaseTexture;
  6337. /** @hidden */ lodTextureLow: BaseTexture;
  6338. /** @hidden */ isRGBD: boolean;
  6339. /** @hidden */ webGLTexture: Nullable<WebGLTexture>;
  6340. /** @hidden */ references: number;
  6341. private _engine;
  6342. /**
  6343. * Gets the Engine the texture belongs to.
  6344. * @returns The babylon engine
  6345. */
  6346. getEngine(): Engine;
  6347. /**
  6348. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6349. */
  6350. readonly dataSource: number;
  6351. /**
  6352. * Creates a new InternalTexture
  6353. * @param engine defines the engine to use
  6354. * @param dataSource defines the type of data that will be used
  6355. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6356. */
  6357. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6358. /**
  6359. * Increments the number of references (ie. the number of Texture that point to it)
  6360. */
  6361. incrementReferences(): void;
  6362. /**
  6363. * Change the size of the texture (not the size of the content)
  6364. * @param width defines the new width
  6365. * @param height defines the new height
  6366. * @param depth defines the new depth (1 by default)
  6367. */
  6368. updateSize(width: int, height: int, depth?: int): void;
  6369. /** @hidden */ rebuild(): void;
  6370. /** @hidden */ swapAndDie(target: InternalTexture): void;
  6371. /**
  6372. * Dispose the current allocated resources
  6373. */
  6374. dispose(): void;
  6375. }
  6376. }
  6377. declare module BABYLON {
  6378. /**
  6379. * This represents the main contract an easing function should follow.
  6380. * Easing functions are used throughout the animation system.
  6381. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6382. */
  6383. export interface IEasingFunction {
  6384. /**
  6385. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6386. * of the easing function.
  6387. * The link below provides some of the most common examples of easing functions.
  6388. * @see https://easings.net/
  6389. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6390. * @returns the corresponding value on the curve defined by the easing function
  6391. */
  6392. ease(gradient: number): number;
  6393. }
  6394. /**
  6395. * Base class used for every default easing function.
  6396. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6397. */
  6398. export class EasingFunction implements IEasingFunction {
  6399. /**
  6400. * Interpolation follows the mathematical formula associated with the easing function.
  6401. */
  6402. static readonly EASINGMODE_EASEIN: number;
  6403. /**
  6404. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6405. */
  6406. static readonly EASINGMODE_EASEOUT: number;
  6407. /**
  6408. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6409. */
  6410. static readonly EASINGMODE_EASEINOUT: number;
  6411. private _easingMode;
  6412. /**
  6413. * Sets the easing mode of the current function.
  6414. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6415. */
  6416. setEasingMode(easingMode: number): void;
  6417. /**
  6418. * Gets the current easing mode.
  6419. * @returns the easing mode
  6420. */
  6421. getEasingMode(): number;
  6422. /**
  6423. * @hidden
  6424. */
  6425. easeInCore(gradient: number): number;
  6426. /**
  6427. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6428. * of the easing function.
  6429. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6430. * @returns the corresponding value on the curve defined by the easing function
  6431. */
  6432. ease(gradient: number): number;
  6433. }
  6434. /**
  6435. * Easing function with a circle shape (see link below).
  6436. * @see https://easings.net/#easeInCirc
  6437. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6438. */
  6439. export class CircleEase extends EasingFunction implements IEasingFunction {
  6440. /** @hidden */
  6441. easeInCore(gradient: number): number;
  6442. }
  6443. /**
  6444. * Easing function with a ease back shape (see link below).
  6445. * @see https://easings.net/#easeInBack
  6446. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6447. */
  6448. export class BackEase extends EasingFunction implements IEasingFunction {
  6449. /** Defines the amplitude of the function */
  6450. amplitude: number;
  6451. /**
  6452. * Instantiates a back ease easing
  6453. * @see https://easings.net/#easeInBack
  6454. * @param amplitude Defines the amplitude of the function
  6455. */
  6456. constructor(
  6457. /** Defines the amplitude of the function */
  6458. amplitude?: number);
  6459. /** @hidden */
  6460. easeInCore(gradient: number): number;
  6461. }
  6462. /**
  6463. * Easing function with a bouncing shape (see link below).
  6464. * @see https://easings.net/#easeInBounce
  6465. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6466. */
  6467. export class BounceEase extends EasingFunction implements IEasingFunction {
  6468. /** Defines the number of bounces */
  6469. bounces: number;
  6470. /** Defines the amplitude of the bounce */
  6471. bounciness: number;
  6472. /**
  6473. * Instantiates a bounce easing
  6474. * @see https://easings.net/#easeInBounce
  6475. * @param bounces Defines the number of bounces
  6476. * @param bounciness Defines the amplitude of the bounce
  6477. */
  6478. constructor(
  6479. /** Defines the number of bounces */
  6480. bounces?: number,
  6481. /** Defines the amplitude of the bounce */
  6482. bounciness?: number);
  6483. /** @hidden */
  6484. easeInCore(gradient: number): number;
  6485. }
  6486. /**
  6487. * Easing function with a power of 3 shape (see link below).
  6488. * @see https://easings.net/#easeInCubic
  6489. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6490. */
  6491. export class CubicEase extends EasingFunction implements IEasingFunction {
  6492. /** @hidden */
  6493. easeInCore(gradient: number): number;
  6494. }
  6495. /**
  6496. * Easing function with an elastic shape (see link below).
  6497. * @see https://easings.net/#easeInElastic
  6498. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6499. */
  6500. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6501. /** Defines the number of oscillations*/
  6502. oscillations: number;
  6503. /** Defines the amplitude of the oscillations*/
  6504. springiness: number;
  6505. /**
  6506. * Instantiates an elastic easing function
  6507. * @see https://easings.net/#easeInElastic
  6508. * @param oscillations Defines the number of oscillations
  6509. * @param springiness Defines the amplitude of the oscillations
  6510. */
  6511. constructor(
  6512. /** Defines the number of oscillations*/
  6513. oscillations?: number,
  6514. /** Defines the amplitude of the oscillations*/
  6515. springiness?: number);
  6516. /** @hidden */
  6517. easeInCore(gradient: number): number;
  6518. }
  6519. /**
  6520. * Easing function with an exponential shape (see link below).
  6521. * @see https://easings.net/#easeInExpo
  6522. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6523. */
  6524. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6525. /** Defines the exponent of the function */
  6526. exponent: number;
  6527. /**
  6528. * Instantiates an exponential easing function
  6529. * @see https://easings.net/#easeInExpo
  6530. * @param exponent Defines the exponent of the function
  6531. */
  6532. constructor(
  6533. /** Defines the exponent of the function */
  6534. exponent?: number);
  6535. /** @hidden */
  6536. easeInCore(gradient: number): number;
  6537. }
  6538. /**
  6539. * Easing function with a power shape (see link below).
  6540. * @see https://easings.net/#easeInQuad
  6541. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6542. */
  6543. export class PowerEase extends EasingFunction implements IEasingFunction {
  6544. /** Defines the power of the function */
  6545. power: number;
  6546. /**
  6547. * Instantiates an power base easing function
  6548. * @see https://easings.net/#easeInQuad
  6549. * @param power Defines the power of the function
  6550. */
  6551. constructor(
  6552. /** Defines the power of the function */
  6553. power?: number);
  6554. /** @hidden */
  6555. easeInCore(gradient: number): number;
  6556. }
  6557. /**
  6558. * Easing function with a power of 2 shape (see link below).
  6559. * @see https://easings.net/#easeInQuad
  6560. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6561. */
  6562. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6563. /** @hidden */
  6564. easeInCore(gradient: number): number;
  6565. }
  6566. /**
  6567. * Easing function with a power of 4 shape (see link below).
  6568. * @see https://easings.net/#easeInQuart
  6569. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6570. */
  6571. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6572. /** @hidden */
  6573. easeInCore(gradient: number): number;
  6574. }
  6575. /**
  6576. * Easing function with a power of 5 shape (see link below).
  6577. * @see https://easings.net/#easeInQuint
  6578. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6579. */
  6580. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6581. /** @hidden */
  6582. easeInCore(gradient: number): number;
  6583. }
  6584. /**
  6585. * Easing function with a sin shape (see link below).
  6586. * @see https://easings.net/#easeInSine
  6587. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6588. */
  6589. export class SineEase extends EasingFunction implements IEasingFunction {
  6590. /** @hidden */
  6591. easeInCore(gradient: number): number;
  6592. }
  6593. /**
  6594. * Easing function with a bezier shape (see link below).
  6595. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6596. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6597. */
  6598. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6599. /** Defines the x component of the start tangent in the bezier curve */
  6600. x1: number;
  6601. /** Defines the y component of the start tangent in the bezier curve */
  6602. y1: number;
  6603. /** Defines the x component of the end tangent in the bezier curve */
  6604. x2: number;
  6605. /** Defines the y component of the end tangent in the bezier curve */
  6606. y2: number;
  6607. /**
  6608. * Instantiates a bezier function
  6609. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6610. * @param x1 Defines the x component of the start tangent in the bezier curve
  6611. * @param y1 Defines the y component of the start tangent in the bezier curve
  6612. * @param x2 Defines the x component of the end tangent in the bezier curve
  6613. * @param y2 Defines the y component of the end tangent in the bezier curve
  6614. */
  6615. constructor(
  6616. /** Defines the x component of the start tangent in the bezier curve */
  6617. x1?: number,
  6618. /** Defines the y component of the start tangent in the bezier curve */
  6619. y1?: number,
  6620. /** Defines the x component of the end tangent in the bezier curve */
  6621. x2?: number,
  6622. /** Defines the y component of the end tangent in the bezier curve */
  6623. y2?: number);
  6624. /** @hidden */
  6625. easeInCore(gradient: number): number;
  6626. }
  6627. }
  6628. declare module BABYLON {
  6629. /**
  6630. * Defines an interface which represents an animation key frame
  6631. */
  6632. export interface IAnimationKey {
  6633. /**
  6634. * Frame of the key frame
  6635. */
  6636. frame: number;
  6637. /**
  6638. * Value at the specifies key frame
  6639. */
  6640. value: any;
  6641. /**
  6642. * The input tangent for the cubic hermite spline
  6643. */
  6644. inTangent?: any;
  6645. /**
  6646. * The output tangent for the cubic hermite spline
  6647. */
  6648. outTangent?: any;
  6649. /**
  6650. * The animation interpolation type
  6651. */
  6652. interpolation?: AnimationKeyInterpolation;
  6653. }
  6654. /**
  6655. * Enum for the animation key frame interpolation type
  6656. */
  6657. export enum AnimationKeyInterpolation {
  6658. /**
  6659. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6660. */
  6661. STEP = 1
  6662. }
  6663. }
  6664. declare module BABYLON {
  6665. /**
  6666. * Represents the range of an animation
  6667. */
  6668. export class AnimationRange {
  6669. /**The name of the animation range**/
  6670. name: string;
  6671. /**The starting frame of the animation */
  6672. from: number;
  6673. /**The ending frame of the animation*/
  6674. to: number;
  6675. /**
  6676. * Initializes the range of an animation
  6677. * @param name The name of the animation range
  6678. * @param from The starting frame of the animation
  6679. * @param to The ending frame of the animation
  6680. */
  6681. constructor(
  6682. /**The name of the animation range**/
  6683. name: string,
  6684. /**The starting frame of the animation */
  6685. from: number,
  6686. /**The ending frame of the animation*/
  6687. to: number);
  6688. /**
  6689. * Makes a copy of the animation range
  6690. * @returns A copy of the animation range
  6691. */
  6692. clone(): AnimationRange;
  6693. }
  6694. }
  6695. declare module BABYLON {
  6696. /**
  6697. * Composed of a frame, and an action function
  6698. */
  6699. export class AnimationEvent {
  6700. /** The frame for which the event is triggered **/
  6701. frame: number;
  6702. /** The event to perform when triggered **/
  6703. action: (currentFrame: number) => void;
  6704. /** Specifies if the event should be triggered only once**/
  6705. onlyOnce?: boolean | undefined;
  6706. /**
  6707. * Specifies if the animation event is done
  6708. */
  6709. isDone: boolean;
  6710. /**
  6711. * Initializes the animation event
  6712. * @param frame The frame for which the event is triggered
  6713. * @param action The event to perform when triggered
  6714. * @param onlyOnce Specifies if the event should be triggered only once
  6715. */
  6716. constructor(
  6717. /** The frame for which the event is triggered **/
  6718. frame: number,
  6719. /** The event to perform when triggered **/
  6720. action: (currentFrame: number) => void,
  6721. /** Specifies if the event should be triggered only once**/
  6722. onlyOnce?: boolean | undefined);
  6723. /** @hidden */ clone(): AnimationEvent;
  6724. }
  6725. }
  6726. declare module BABYLON {
  6727. /**
  6728. * Interface used to define a behavior
  6729. */
  6730. export interface Behavior<T> {
  6731. /** gets or sets behavior's name */
  6732. name: string;
  6733. /**
  6734. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6735. */
  6736. init(): void;
  6737. /**
  6738. * Called when the behavior is attached to a target
  6739. * @param target defines the target where the behavior is attached to
  6740. */
  6741. attach(target: T): void;
  6742. /**
  6743. * Called when the behavior is detached from its target
  6744. */
  6745. detach(): void;
  6746. }
  6747. /**
  6748. * Interface implemented by classes supporting behaviors
  6749. */
  6750. export interface IBehaviorAware<T> {
  6751. /**
  6752. * Attach a behavior
  6753. * @param behavior defines the behavior to attach
  6754. * @returns the current host
  6755. */
  6756. addBehavior(behavior: Behavior<T>): T;
  6757. /**
  6758. * Remove a behavior from the current object
  6759. * @param behavior defines the behavior to detach
  6760. * @returns the current host
  6761. */
  6762. removeBehavior(behavior: Behavior<T>): T;
  6763. /**
  6764. * Gets a behavior using its name to search
  6765. * @param name defines the name to search
  6766. * @returns the behavior or null if not found
  6767. */
  6768. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6769. }
  6770. }
  6771. declare module BABYLON {
  6772. /**
  6773. * @hidden
  6774. */
  6775. export class IntersectionInfo {
  6776. bu: Nullable<number>;
  6777. bv: Nullable<number>;
  6778. distance: number;
  6779. faceId: number;
  6780. subMeshId: number;
  6781. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6782. }
  6783. }
  6784. declare module BABYLON {
  6785. /**
  6786. * Class used to store bounding sphere information
  6787. */
  6788. export class BoundingSphere {
  6789. /**
  6790. * Gets the center of the bounding sphere in local space
  6791. */
  6792. readonly center: Vector3;
  6793. /**
  6794. * Radius of the bounding sphere in local space
  6795. */
  6796. radius: number;
  6797. /**
  6798. * Gets the center of the bounding sphere in world space
  6799. */
  6800. readonly centerWorld: Vector3;
  6801. /**
  6802. * Radius of the bounding sphere in world space
  6803. */
  6804. radiusWorld: number;
  6805. /**
  6806. * Gets the minimum vector in local space
  6807. */
  6808. readonly minimum: Vector3;
  6809. /**
  6810. * Gets the maximum vector in local space
  6811. */
  6812. readonly maximum: Vector3;
  6813. private _worldMatrix;
  6814. private static readonly TmpVector3;
  6815. /**
  6816. * Creates a new bounding sphere
  6817. * @param min defines the minimum vector (in local space)
  6818. * @param max defines the maximum vector (in local space)
  6819. * @param worldMatrix defines the new world matrix
  6820. */
  6821. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6822. /**
  6823. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6824. * @param min defines the new minimum vector (in local space)
  6825. * @param max defines the new maximum vector (in local space)
  6826. * @param worldMatrix defines the new world matrix
  6827. */
  6828. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6829. /**
  6830. * Scale the current bounding sphere by applying a scale factor
  6831. * @param factor defines the scale factor to apply
  6832. * @returns the current bounding box
  6833. */
  6834. scale(factor: number): BoundingSphere;
  6835. /**
  6836. * Gets the world matrix of the bounding box
  6837. * @returns a matrix
  6838. */
  6839. getWorldMatrix(): DeepImmutable<Matrix>;
  6840. /** @hidden */ update(worldMatrix: DeepImmutable<Matrix>): void;
  6841. /**
  6842. * Tests if the bounding sphere is intersecting the frustum planes
  6843. * @param frustumPlanes defines the frustum planes to test
  6844. * @returns true if there is an intersection
  6845. */
  6846. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6847. /**
  6848. * Tests if the bounding sphere center is in between the frustum planes.
  6849. * Used for optimistic fast inclusion.
  6850. * @param frustumPlanes defines the frustum planes to test
  6851. * @returns true if the sphere center is in between the frustum planes
  6852. */
  6853. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6854. /**
  6855. * Tests if a point is inside the bounding sphere
  6856. * @param point defines the point to test
  6857. * @returns true if the point is inside the bounding sphere
  6858. */
  6859. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6860. /**
  6861. * Checks if two sphere intersct
  6862. * @param sphere0 sphere 0
  6863. * @param sphere1 sphere 1
  6864. * @returns true if the speres intersect
  6865. */
  6866. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6867. }
  6868. }
  6869. declare module BABYLON {
  6870. /**
  6871. * Class used to store bounding box information
  6872. */
  6873. export class BoundingBox implements ICullable {
  6874. /**
  6875. * Gets the 8 vectors representing the bounding box in local space
  6876. */
  6877. readonly vectors: Vector3[];
  6878. /**
  6879. * Gets the center of the bounding box in local space
  6880. */
  6881. readonly center: Vector3;
  6882. /**
  6883. * Gets the center of the bounding box in world space
  6884. */
  6885. readonly centerWorld: Vector3;
  6886. /**
  6887. * Gets the extend size in local space
  6888. */
  6889. readonly extendSize: Vector3;
  6890. /**
  6891. * Gets the extend size in world space
  6892. */
  6893. readonly extendSizeWorld: Vector3;
  6894. /**
  6895. * Gets the OBB (object bounding box) directions
  6896. */
  6897. readonly directions: Vector3[];
  6898. /**
  6899. * Gets the 8 vectors representing the bounding box in world space
  6900. */
  6901. readonly vectorsWorld: Vector3[];
  6902. /**
  6903. * Gets the minimum vector in world space
  6904. */
  6905. readonly minimumWorld: Vector3;
  6906. /**
  6907. * Gets the maximum vector in world space
  6908. */
  6909. readonly maximumWorld: Vector3;
  6910. /**
  6911. * Gets the minimum vector in local space
  6912. */
  6913. readonly minimum: Vector3;
  6914. /**
  6915. * Gets the maximum vector in local space
  6916. */
  6917. readonly maximum: Vector3;
  6918. private _worldMatrix;
  6919. private static readonly TmpVector3;
  6920. /**
  6921. * @hidden
  6922. */ tag: number;
  6923. /**
  6924. * Creates a new bounding box
  6925. * @param min defines the minimum vector (in local space)
  6926. * @param max defines the maximum vector (in local space)
  6927. * @param worldMatrix defines the new world matrix
  6928. */
  6929. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6930. /**
  6931. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6932. * @param min defines the new minimum vector (in local space)
  6933. * @param max defines the new maximum vector (in local space)
  6934. * @param worldMatrix defines the new world matrix
  6935. */
  6936. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6937. /**
  6938. * Scale the current bounding box by applying a scale factor
  6939. * @param factor defines the scale factor to apply
  6940. * @returns the current bounding box
  6941. */
  6942. scale(factor: number): BoundingBox;
  6943. /**
  6944. * Gets the world matrix of the bounding box
  6945. * @returns a matrix
  6946. */
  6947. getWorldMatrix(): DeepImmutable<Matrix>;
  6948. /** @hidden */ update(world: DeepImmutable<Matrix>): void;
  6949. /**
  6950. * Tests if the bounding box is intersecting the frustum planes
  6951. * @param frustumPlanes defines the frustum planes to test
  6952. * @returns true if there is an intersection
  6953. */
  6954. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6955. /**
  6956. * Tests if the bounding box is entirely inside the frustum planes
  6957. * @param frustumPlanes defines the frustum planes to test
  6958. * @returns true if there is an inclusion
  6959. */
  6960. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6961. /**
  6962. * Tests if a point is inside the bounding box
  6963. * @param point defines the point to test
  6964. * @returns true if the point is inside the bounding box
  6965. */
  6966. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6967. /**
  6968. * Tests if the bounding box intersects with a bounding sphere
  6969. * @param sphere defines the sphere to test
  6970. * @returns true if there is an intersection
  6971. */
  6972. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6973. /**
  6974. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6975. * @param min defines the min vector to use
  6976. * @param max defines the max vector to use
  6977. * @returns true if there is an intersection
  6978. */
  6979. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6980. /**
  6981. * Tests if two bounding boxes are intersections
  6982. * @param box0 defines the first box to test
  6983. * @param box1 defines the second box to test
  6984. * @returns true if there is an intersection
  6985. */
  6986. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6987. /**
  6988. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6989. * @param minPoint defines the minimum vector of the bounding box
  6990. * @param maxPoint defines the maximum vector of the bounding box
  6991. * @param sphereCenter defines the sphere center
  6992. * @param sphereRadius defines the sphere radius
  6993. * @returns true if there is an intersection
  6994. */
  6995. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6996. /**
  6997. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6998. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6999. * @param frustumPlanes defines the frustum planes to test
  7000. * @return true if there is an inclusion
  7001. */
  7002. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7003. /**
  7004. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7005. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7006. * @param frustumPlanes defines the frustum planes to test
  7007. * @return true if there is an intersection
  7008. */
  7009. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7010. }
  7011. }
  7012. declare module BABYLON {
  7013. /** @hidden */
  7014. export class Collider {
  7015. /** Define if a collision was found */
  7016. collisionFound: boolean;
  7017. /**
  7018. * Define last intersection point in local space
  7019. */
  7020. intersectionPoint: Vector3;
  7021. /**
  7022. * Define last collided mesh
  7023. */
  7024. collidedMesh: Nullable<AbstractMesh>;
  7025. private _collisionPoint;
  7026. private _planeIntersectionPoint;
  7027. private _tempVector;
  7028. private _tempVector2;
  7029. private _tempVector3;
  7030. private _tempVector4;
  7031. private _edge;
  7032. private _baseToVertex;
  7033. private _destinationPoint;
  7034. private _slidePlaneNormal;
  7035. private _displacementVector;
  7036. /** @hidden */ radius: Vector3;
  7037. /** @hidden */ retry: number;
  7038. private _velocity;
  7039. private _basePoint;
  7040. private _epsilon;
  7041. /** @hidden */ velocityWorldLength: number;
  7042. /** @hidden */ basePointWorld: Vector3;
  7043. private _velocityWorld;
  7044. private _normalizedVelocity;
  7045. /** @hidden */ initialVelocity: Vector3;
  7046. /** @hidden */ initialPosition: Vector3;
  7047. private _nearestDistance;
  7048. private _collisionMask;
  7049. collisionMask: number;
  7050. /**
  7051. * Gets the plane normal used to compute the sliding response (in local space)
  7052. */
  7053. readonly slidePlaneNormal: Vector3;
  7054. /** @hidden */ initialize(source: Vector3, dir: Vector3, e: number): void;
  7055. /** @hidden */ checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7056. /** @hidden */ canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7057. /** @hidden */ testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7058. /** @hidden */ collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7059. /** @hidden */ getResponse(pos: Vector3, vel: Vector3): void;
  7060. }
  7061. }
  7062. declare module BABYLON {
  7063. /**
  7064. * Interface for cullable objects
  7065. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7066. */
  7067. export interface ICullable {
  7068. /**
  7069. * Checks if the object or part of the object is in the frustum
  7070. * @param frustumPlanes Camera near/planes
  7071. * @returns true if the object is in frustum otherwise false
  7072. */
  7073. isInFrustum(frustumPlanes: Plane[]): boolean;
  7074. /**
  7075. * Checks if a cullable object (mesh...) is in the camera frustum
  7076. * Unlike isInFrustum this cheks the full bounding box
  7077. * @param frustumPlanes Camera near/planes
  7078. * @returns true if the object is in frustum otherwise false
  7079. */
  7080. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7081. }
  7082. /**
  7083. * Info for a bounding data of a mesh
  7084. */
  7085. export class BoundingInfo implements ICullable {
  7086. /**
  7087. * Bounding box for the mesh
  7088. */
  7089. readonly boundingBox: BoundingBox;
  7090. /**
  7091. * Bounding sphere for the mesh
  7092. */
  7093. readonly boundingSphere: BoundingSphere;
  7094. private _isLocked;
  7095. private static readonly TmpVector3;
  7096. /**
  7097. * Constructs bounding info
  7098. * @param minimum min vector of the bounding box/sphere
  7099. * @param maximum max vector of the bounding box/sphere
  7100. * @param worldMatrix defines the new world matrix
  7101. */
  7102. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7103. /**
  7104. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7105. * @param min defines the new minimum vector (in local space)
  7106. * @param max defines the new maximum vector (in local space)
  7107. * @param worldMatrix defines the new world matrix
  7108. */
  7109. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7110. /**
  7111. * min vector of the bounding box/sphere
  7112. */
  7113. readonly minimum: Vector3;
  7114. /**
  7115. * max vector of the bounding box/sphere
  7116. */
  7117. readonly maximum: Vector3;
  7118. /**
  7119. * If the info is locked and won't be updated to avoid perf overhead
  7120. */
  7121. isLocked: boolean;
  7122. /**
  7123. * Updates the bounding sphere and box
  7124. * @param world world matrix to be used to update
  7125. */
  7126. update(world: DeepImmutable<Matrix>): void;
  7127. /**
  7128. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7129. * @param center New center of the bounding info
  7130. * @param extend New extend of the bounding info
  7131. * @returns the current bounding info
  7132. */
  7133. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7134. /**
  7135. * Scale the current bounding info by applying a scale factor
  7136. * @param factor defines the scale factor to apply
  7137. * @returns the current bounding info
  7138. */
  7139. scale(factor: number): BoundingInfo;
  7140. /**
  7141. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7142. * @param frustumPlanes defines the frustum to test
  7143. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7144. * @returns true if the bounding info is in the frustum planes
  7145. */
  7146. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7147. /**
  7148. * Gets the world distance between the min and max points of the bounding box
  7149. */
  7150. readonly diagonalLength: number;
  7151. /**
  7152. * Checks if a cullable object (mesh...) is in the camera frustum
  7153. * Unlike isInFrustum this cheks the full bounding box
  7154. * @param frustumPlanes Camera near/planes
  7155. * @returns true if the object is in frustum otherwise false
  7156. */
  7157. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7158. /** @hidden */ checkCollision(collider: Collider): boolean;
  7159. /**
  7160. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7161. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7162. * @param point the point to check intersection with
  7163. * @returns if the point intersects
  7164. */
  7165. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7166. /**
  7167. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7168. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7169. * @param boundingInfo the bounding info to check intersection with
  7170. * @param precise if the intersection should be done using OBB
  7171. * @returns if the bounding info intersects
  7172. */
  7173. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7174. }
  7175. }
  7176. declare module BABYLON {
  7177. /**
  7178. * Defines an array and its length.
  7179. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7180. */
  7181. export interface ISmartArrayLike<T> {
  7182. /**
  7183. * The data of the array.
  7184. */
  7185. data: Array<T>;
  7186. /**
  7187. * The active length of the array.
  7188. */
  7189. length: number;
  7190. }
  7191. /**
  7192. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7193. */
  7194. export class SmartArray<T> implements ISmartArrayLike<T> {
  7195. /**
  7196. * The full set of data from the array.
  7197. */
  7198. data: Array<T>;
  7199. /**
  7200. * The active length of the array.
  7201. */
  7202. length: number;
  7203. protected _id: number;
  7204. /**
  7205. * Instantiates a Smart Array.
  7206. * @param capacity defines the default capacity of the array.
  7207. */
  7208. constructor(capacity: number);
  7209. /**
  7210. * Pushes a value at the end of the active data.
  7211. * @param value defines the object to push in the array.
  7212. */
  7213. push(value: T): void;
  7214. /**
  7215. * Iterates over the active data and apply the lambda to them.
  7216. * @param func defines the action to apply on each value.
  7217. */
  7218. forEach(func: (content: T) => void): void;
  7219. /**
  7220. * Sorts the full sets of data.
  7221. * @param compareFn defines the comparison function to apply.
  7222. */
  7223. sort(compareFn: (a: T, b: T) => number): void;
  7224. /**
  7225. * Resets the active data to an empty array.
  7226. */
  7227. reset(): void;
  7228. /**
  7229. * Releases all the data from the array as well as the array.
  7230. */
  7231. dispose(): void;
  7232. /**
  7233. * Concats the active data with a given array.
  7234. * @param array defines the data to concatenate with.
  7235. */
  7236. concat(array: any): void;
  7237. /**
  7238. * Returns the position of a value in the active data.
  7239. * @param value defines the value to find the index for
  7240. * @returns the index if found in the active data otherwise -1
  7241. */
  7242. indexOf(value: T): number;
  7243. /**
  7244. * Returns whether an element is part of the active data.
  7245. * @param value defines the value to look for
  7246. * @returns true if found in the active data otherwise false
  7247. */
  7248. contains(value: T): boolean;
  7249. private static _GlobalId;
  7250. }
  7251. /**
  7252. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7253. * The data in this array can only be present once
  7254. */
  7255. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7256. private _duplicateId;
  7257. /**
  7258. * Pushes a value at the end of the active data.
  7259. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7260. * @param value defines the object to push in the array.
  7261. */
  7262. push(value: T): void;
  7263. /**
  7264. * Pushes a value at the end of the active data.
  7265. * If the data is already present, it won t be added again
  7266. * @param value defines the object to push in the array.
  7267. * @returns true if added false if it was already present
  7268. */
  7269. pushNoDuplicate(value: T): boolean;
  7270. /**
  7271. * Resets the active data to an empty array.
  7272. */
  7273. reset(): void;
  7274. /**
  7275. * Concats the active data with a given array.
  7276. * This ensures no dupplicate will be present in the result.
  7277. * @param array defines the data to concatenate with.
  7278. */
  7279. concatWithNoDuplicate(array: any): void;
  7280. }
  7281. }
  7282. declare module BABYLON {
  7283. /**
  7284. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7285. * separate meshes. This can be use to improve performances.
  7286. * @see http://doc.babylonjs.com/how_to/multi_materials
  7287. */
  7288. export class MultiMaterial extends Material {
  7289. private _subMaterials;
  7290. /**
  7291. * Gets or Sets the list of Materials used within the multi material.
  7292. * They need to be ordered according to the submeshes order in the associated mesh
  7293. */
  7294. subMaterials: Nullable<Material>[];
  7295. /**
  7296. * Function used to align with Node.getChildren()
  7297. * @returns the list of Materials used within the multi material
  7298. */
  7299. getChildren(): Nullable<Material>[];
  7300. /**
  7301. * Instantiates a new Multi Material
  7302. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7303. * separate meshes. This can be use to improve performances.
  7304. * @see http://doc.babylonjs.com/how_to/multi_materials
  7305. * @param name Define the name in the scene
  7306. * @param scene Define the scene the material belongs to
  7307. */
  7308. constructor(name: string, scene: Scene);
  7309. private _hookArray;
  7310. /**
  7311. * Get one of the submaterial by its index in the submaterials array
  7312. * @param index The index to look the sub material at
  7313. * @returns The Material if the index has been defined
  7314. */
  7315. getSubMaterial(index: number): Nullable<Material>;
  7316. /**
  7317. * Get the list of active textures for the whole sub materials list.
  7318. * @returns All the textures that will be used during the rendering
  7319. */
  7320. getActiveTextures(): BaseTexture[];
  7321. /**
  7322. * Gets the current class name of the material e.g. "MultiMaterial"
  7323. * Mainly use in serialization.
  7324. * @returns the class name
  7325. */
  7326. getClassName(): string;
  7327. /**
  7328. * Checks if the material is ready to render the requested sub mesh
  7329. * @param mesh Define the mesh the submesh belongs to
  7330. * @param subMesh Define the sub mesh to look readyness for
  7331. * @param useInstances Define whether or not the material is used with instances
  7332. * @returns true if ready, otherwise false
  7333. */
  7334. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7335. /**
  7336. * Clones the current material and its related sub materials
  7337. * @param name Define the name of the newly cloned material
  7338. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7339. * @returns the cloned material
  7340. */
  7341. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7342. /**
  7343. * Serializes the materials into a JSON representation.
  7344. * @returns the JSON representation
  7345. */
  7346. serialize(): any;
  7347. /**
  7348. * Dispose the material and release its associated resources
  7349. * @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)
  7350. * @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)
  7351. * @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)
  7352. */
  7353. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7354. /**
  7355. * Creates a MultiMaterial from parsed MultiMaterial data.
  7356. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7357. * @param scene defines the hosting scene
  7358. * @returns a new MultiMaterial
  7359. */
  7360. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7361. }
  7362. }
  7363. declare module BABYLON {
  7364. /**
  7365. * Class used to represent data loading progression
  7366. */
  7367. export class SceneLoaderFlags {
  7368. private static _ForceFullSceneLoadingForIncremental;
  7369. private static _ShowLoadingScreen;
  7370. private static _CleanBoneMatrixWeights;
  7371. private static _loggingLevel;
  7372. /**
  7373. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7374. */
  7375. static ForceFullSceneLoadingForIncremental: boolean;
  7376. /**
  7377. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7378. */
  7379. static ShowLoadingScreen: boolean;
  7380. /**
  7381. * Defines the current logging level (while loading the scene)
  7382. * @ignorenaming
  7383. */
  7384. static loggingLevel: number;
  7385. /**
  7386. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7387. */
  7388. static CleanBoneMatrixWeights: boolean;
  7389. }
  7390. }
  7391. declare module BABYLON {
  7392. /**
  7393. * 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.
  7394. * @see https://doc.babylonjs.com/how_to/transformnode
  7395. */
  7396. export class TransformNode extends Node {
  7397. /**
  7398. * Object will not rotate to face the camera
  7399. */
  7400. static BILLBOARDMODE_NONE: number;
  7401. /**
  7402. * Object will rotate to face the camera but only on the x axis
  7403. */
  7404. static BILLBOARDMODE_X: number;
  7405. /**
  7406. * Object will rotate to face the camera but only on the y axis
  7407. */
  7408. static BILLBOARDMODE_Y: number;
  7409. /**
  7410. * Object will rotate to face the camera but only on the z axis
  7411. */
  7412. static BILLBOARDMODE_Z: number;
  7413. /**
  7414. * Object will rotate to face the camera
  7415. */
  7416. static BILLBOARDMODE_ALL: number;
  7417. private _forward;
  7418. private _forwardInverted;
  7419. private _up;
  7420. private _right;
  7421. private _rightInverted;
  7422. private _position;
  7423. private _rotation;
  7424. private _rotationQuaternion;
  7425. protected _scaling: Vector3;
  7426. protected _isDirty: boolean;
  7427. private _transformToBoneReferal;
  7428. /**
  7429. * Set the billboard mode. Default is 0.
  7430. *
  7431. * | Value | Type | Description |
  7432. * | --- | --- | --- |
  7433. * | 0 | BILLBOARDMODE_NONE | |
  7434. * | 1 | BILLBOARDMODE_X | |
  7435. * | 2 | BILLBOARDMODE_Y | |
  7436. * | 4 | BILLBOARDMODE_Z | |
  7437. * | 7 | BILLBOARDMODE_ALL | |
  7438. *
  7439. */
  7440. billboardMode: number;
  7441. /**
  7442. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7443. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7444. */
  7445. preserveParentRotationForBillboard: boolean;
  7446. /**
  7447. * 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
  7448. */
  7449. scalingDeterminant: number;
  7450. /**
  7451. * Sets the distance of the object to max, often used by skybox
  7452. */
  7453. infiniteDistance: boolean;
  7454. /**
  7455. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7456. * By default the system will update normals to compensate
  7457. */
  7458. ignoreNonUniformScaling: boolean;
  7459. /** @hidden */ poseMatrix: Matrix;
  7460. /** @hidden */ localMatrix: Matrix;
  7461. private _absolutePosition;
  7462. private _pivotMatrix;
  7463. private _pivotMatrixInverse;
  7464. protected _postMultiplyPivotMatrix: boolean;
  7465. private _tempMatrix;
  7466. private _tempMatrix2;
  7467. protected _isWorldMatrixFrozen: boolean;
  7468. /** @hidden */ indexInSceneTransformNodesArray: number;
  7469. /**
  7470. * An event triggered after the world matrix is updated
  7471. */
  7472. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7473. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7474. /**
  7475. * Gets a string identifying the name of the class
  7476. * @returns "TransformNode" string
  7477. */
  7478. getClassName(): string;
  7479. /**
  7480. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7481. */
  7482. position: Vector3;
  7483. /**
  7484. * 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)).
  7485. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7486. */
  7487. rotation: Vector3;
  7488. /**
  7489. * 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)).
  7490. */
  7491. scaling: Vector3;
  7492. /**
  7493. * 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).
  7494. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7495. */
  7496. rotationQuaternion: Nullable<Quaternion>;
  7497. /**
  7498. * The forward direction of that transform in world space.
  7499. */
  7500. readonly forward: Vector3;
  7501. /**
  7502. * The up direction of that transform in world space.
  7503. */
  7504. readonly up: Vector3;
  7505. /**
  7506. * The right direction of that transform in world space.
  7507. */
  7508. readonly right: Vector3;
  7509. /**
  7510. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7511. * @param matrix the matrix to copy the pose from
  7512. * @returns this TransformNode.
  7513. */
  7514. updatePoseMatrix(matrix: Matrix): TransformNode;
  7515. /**
  7516. * Returns the mesh Pose matrix.
  7517. * @returns the pose matrix
  7518. */
  7519. getPoseMatrix(): Matrix;
  7520. /** @hidden */ isSynchronized(): boolean;
  7521. /** @hidden */ initCache(): void;
  7522. /**
  7523. * Flag the transform node as dirty (Forcing it to update everything)
  7524. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7525. * @returns this transform node
  7526. */
  7527. markAsDirty(property: string): TransformNode;
  7528. /**
  7529. * Returns the current mesh absolute position.
  7530. * Returns a Vector3.
  7531. */
  7532. readonly absolutePosition: Vector3;
  7533. /**
  7534. * Sets a new matrix to apply before all other transformation
  7535. * @param matrix defines the transform matrix
  7536. * @returns the current TransformNode
  7537. */
  7538. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7539. /**
  7540. * Sets a new pivot matrix to the current node
  7541. * @param matrix defines the new pivot matrix to use
  7542. * @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
  7543. * @returns the current TransformNode
  7544. */
  7545. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7546. /**
  7547. * Returns the mesh pivot matrix.
  7548. * Default : Identity.
  7549. * @returns the matrix
  7550. */
  7551. getPivotMatrix(): Matrix;
  7552. /**
  7553. * Prevents the World matrix to be computed any longer.
  7554. * @returns the TransformNode.
  7555. */
  7556. freezeWorldMatrix(): TransformNode;
  7557. /**
  7558. * Allows back the World matrix computation.
  7559. * @returns the TransformNode.
  7560. */
  7561. unfreezeWorldMatrix(): this;
  7562. /**
  7563. * True if the World matrix has been frozen.
  7564. */
  7565. readonly isWorldMatrixFrozen: boolean;
  7566. /**
  7567. * Retuns the mesh absolute position in the World.
  7568. * @returns a Vector3.
  7569. */
  7570. getAbsolutePosition(): Vector3;
  7571. /**
  7572. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7573. * @param absolutePosition the absolute position to set
  7574. * @returns the TransformNode.
  7575. */
  7576. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7577. /**
  7578. * Sets the mesh position in its local space.
  7579. * @param vector3 the position to set in localspace
  7580. * @returns the TransformNode.
  7581. */
  7582. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7583. /**
  7584. * Returns the mesh position in the local space from the current World matrix values.
  7585. * @returns a new Vector3.
  7586. */
  7587. getPositionExpressedInLocalSpace(): Vector3;
  7588. /**
  7589. * Translates the mesh along the passed Vector3 in its local space.
  7590. * @param vector3 the distance to translate in localspace
  7591. * @returns the TransformNode.
  7592. */
  7593. locallyTranslate(vector3: Vector3): TransformNode;
  7594. private static _lookAtVectorCache;
  7595. /**
  7596. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7597. * @param targetPoint the position (must be in same space as current mesh) to look at
  7598. * @param yawCor optional yaw (y-axis) correction in radians
  7599. * @param pitchCor optional pitch (x-axis) correction in radians
  7600. * @param rollCor optional roll (z-axis) correction in radians
  7601. * @param space the choosen space of the target
  7602. * @returns the TransformNode.
  7603. */
  7604. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7605. /**
  7606. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7607. * This Vector3 is expressed in the World space.
  7608. * @param localAxis axis to rotate
  7609. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7610. */
  7611. getDirection(localAxis: Vector3): Vector3;
  7612. /**
  7613. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7614. * localAxis is expressed in the mesh local space.
  7615. * result is computed in the Wordl space from the mesh World matrix.
  7616. * @param localAxis axis to rotate
  7617. * @param result the resulting transformnode
  7618. * @returns this TransformNode.
  7619. */
  7620. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7621. /**
  7622. * Sets this transform node rotation to the given local axis.
  7623. * @param localAxis the axis in local space
  7624. * @param yawCor optional yaw (y-axis) correction in radians
  7625. * @param pitchCor optional pitch (x-axis) correction in radians
  7626. * @param rollCor optional roll (z-axis) correction in radians
  7627. * @returns this TransformNode
  7628. */
  7629. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7630. /**
  7631. * Sets a new pivot point to the current node
  7632. * @param point defines the new pivot point to use
  7633. * @param space defines if the point is in world or local space (local by default)
  7634. * @returns the current TransformNode
  7635. */
  7636. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7637. /**
  7638. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7639. * @returns the pivot point
  7640. */
  7641. getPivotPoint(): Vector3;
  7642. /**
  7643. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7644. * @param result the vector3 to store the result
  7645. * @returns this TransformNode.
  7646. */
  7647. getPivotPointToRef(result: Vector3): TransformNode;
  7648. /**
  7649. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7650. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7651. */
  7652. getAbsolutePivotPoint(): Vector3;
  7653. /**
  7654. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7655. * @param result vector3 to store the result
  7656. * @returns this TransformNode.
  7657. */
  7658. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7659. /**
  7660. * Defines the passed node as the parent of the current node.
  7661. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7662. * @see https://doc.babylonjs.com/how_to/parenting
  7663. * @param node the node ot set as the parent
  7664. * @returns this TransformNode.
  7665. */
  7666. setParent(node: Nullable<Node>): TransformNode;
  7667. private _nonUniformScaling;
  7668. /**
  7669. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7670. */
  7671. readonly nonUniformScaling: boolean;
  7672. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  7673. /**
  7674. * Attach the current TransformNode to another TransformNode associated with a bone
  7675. * @param bone Bone affecting the TransformNode
  7676. * @param affectedTransformNode TransformNode associated with the bone
  7677. * @returns this object
  7678. */
  7679. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7680. /**
  7681. * Detach the transform node if its associated with a bone
  7682. * @returns this object
  7683. */
  7684. detachFromBone(): TransformNode;
  7685. private static _rotationAxisCache;
  7686. /**
  7687. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7688. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7689. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7690. * The passed axis is also normalized.
  7691. * @param axis the axis to rotate around
  7692. * @param amount the amount to rotate in radians
  7693. * @param space Space to rotate in (Default: local)
  7694. * @returns the TransformNode.
  7695. */
  7696. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7697. /**
  7698. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7699. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7700. * The passed axis is also normalized. .
  7701. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7702. * @param point the point to rotate around
  7703. * @param axis the axis to rotate around
  7704. * @param amount the amount to rotate in radians
  7705. * @returns the TransformNode
  7706. */
  7707. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7708. /**
  7709. * Translates the mesh along the axis vector for the passed distance in the given space.
  7710. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7711. * @param axis the axis to translate in
  7712. * @param distance the distance to translate
  7713. * @param space Space to rotate in (Default: local)
  7714. * @returns the TransformNode.
  7715. */
  7716. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7717. /**
  7718. * Adds a rotation step to the mesh current rotation.
  7719. * x, y, z are Euler angles expressed in radians.
  7720. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7721. * This means this rotation is made in the mesh local space only.
  7722. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7723. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7724. * ```javascript
  7725. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7726. * ```
  7727. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7728. * 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.
  7729. * @param x Rotation to add
  7730. * @param y Rotation to add
  7731. * @param z Rotation to add
  7732. * @returns the TransformNode.
  7733. */
  7734. addRotation(x: number, y: number, z: number): TransformNode;
  7735. /**
  7736. * @hidden
  7737. */
  7738. protected _getEffectiveParent(): Nullable<Node>;
  7739. /**
  7740. * Computes the world matrix of the node
  7741. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7742. * @returns the world matrix
  7743. */
  7744. computeWorldMatrix(force?: boolean): Matrix;
  7745. protected _afterComputeWorldMatrix(): void;
  7746. /**
  7747. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7748. * @param func callback function to add
  7749. *
  7750. * @returns the TransformNode.
  7751. */
  7752. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7753. /**
  7754. * Removes a registered callback function.
  7755. * @param func callback function to remove
  7756. * @returns the TransformNode.
  7757. */
  7758. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7759. /**
  7760. * Gets the position of the current mesh in camera space
  7761. * @param camera defines the camera to use
  7762. * @returns a position
  7763. */
  7764. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7765. /**
  7766. * Returns the distance from the mesh to the active camera
  7767. * @param camera defines the camera to use
  7768. * @returns the distance
  7769. */
  7770. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7771. /**
  7772. * Clone the current transform node
  7773. * @param name Name of the new clone
  7774. * @param newParent New parent for the clone
  7775. * @param doNotCloneChildren Do not clone children hierarchy
  7776. * @returns the new transform node
  7777. */
  7778. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7779. /**
  7780. * Serializes the objects information.
  7781. * @param currentSerializationObject defines the object to serialize in
  7782. * @returns the serialized object
  7783. */
  7784. serialize(currentSerializationObject?: any): any;
  7785. /**
  7786. * Returns a new TransformNode object parsed from the source provided.
  7787. * @param parsedTransformNode is the source.
  7788. * @param scene the scne the object belongs to
  7789. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7790. * @returns a new TransformNode object parsed from the source provided.
  7791. */
  7792. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7793. /**
  7794. * Get all child-transformNodes of this node
  7795. * @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
  7796. * @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
  7797. * @returns an array of TransformNode
  7798. */
  7799. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7800. /**
  7801. * Releases resources associated with this transform node.
  7802. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7803. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7804. */
  7805. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7806. }
  7807. }
  7808. declare module BABYLON {
  7809. /**
  7810. * Class used to override all child animations of a given target
  7811. */
  7812. export class AnimationPropertiesOverride {
  7813. /**
  7814. * Gets or sets a value indicating if animation blending must be used
  7815. */
  7816. enableBlending: boolean;
  7817. /**
  7818. * Gets or sets the blending speed to use when enableBlending is true
  7819. */
  7820. blendingSpeed: number;
  7821. /**
  7822. * Gets or sets the default loop mode to use
  7823. */
  7824. loopMode: number;
  7825. }
  7826. }
  7827. declare module BABYLON {
  7828. /**
  7829. * Class used to store bone information
  7830. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7831. */
  7832. export class Bone extends Node {
  7833. /**
  7834. * defines the bone name
  7835. */
  7836. name: string;
  7837. private static _tmpVecs;
  7838. private static _tmpQuat;
  7839. private static _tmpMats;
  7840. /**
  7841. * Gets the list of child bones
  7842. */
  7843. children: Bone[];
  7844. /** Gets the animations associated with this bone */
  7845. animations: Animation[];
  7846. /**
  7847. * Gets or sets bone length
  7848. */
  7849. length: number;
  7850. /**
  7851. * @hidden Internal only
  7852. * Set this value to map this bone to a different index in the transform matrices
  7853. * Set this value to -1 to exclude the bone from the transform matrices
  7854. */ index: Nullable<number>;
  7855. private _skeleton;
  7856. private _localMatrix;
  7857. private _restPose;
  7858. private _baseMatrix;
  7859. private _absoluteTransform;
  7860. private _invertedAbsoluteTransform;
  7861. private _parent;
  7862. private _scalingDeterminant;
  7863. private _worldTransform;
  7864. private _localScaling;
  7865. private _localRotation;
  7866. private _localPosition;
  7867. private _needToDecompose;
  7868. private _needToCompose;
  7869. /** @hidden */ linkedTransformNode: Nullable<TransformNode>;
  7870. /** @hidden */
  7871. /** @hidden */ matrix: Matrix;
  7872. /**
  7873. * Create a new bone
  7874. * @param name defines the bone name
  7875. * @param skeleton defines the parent skeleton
  7876. * @param parentBone defines the parent (can be null if the bone is the root)
  7877. * @param localMatrix defines the local matrix
  7878. * @param restPose defines the rest pose matrix
  7879. * @param baseMatrix defines the base matrix
  7880. * @param index defines index of the bone in the hiearchy
  7881. */
  7882. constructor(
  7883. /**
  7884. * defines the bone name
  7885. */
  7886. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7887. /**
  7888. * Gets the current object class name.
  7889. * @return the class name
  7890. */
  7891. getClassName(): string;
  7892. /**
  7893. * Gets the parent skeleton
  7894. * @returns a skeleton
  7895. */
  7896. getSkeleton(): Skeleton;
  7897. /**
  7898. * Gets parent bone
  7899. * @returns a bone or null if the bone is the root of the bone hierarchy
  7900. */
  7901. getParent(): Nullable<Bone>;
  7902. /**
  7903. * Returns an array containing the root bones
  7904. * @returns an array containing the root bones
  7905. */
  7906. getChildren(): Array<Bone>;
  7907. /**
  7908. * Sets the parent bone
  7909. * @param parent defines the parent (can be null if the bone is the root)
  7910. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7911. */
  7912. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7913. /**
  7914. * Gets the local matrix
  7915. * @returns a matrix
  7916. */
  7917. getLocalMatrix(): Matrix;
  7918. /**
  7919. * Gets the base matrix (initial matrix which remains unchanged)
  7920. * @returns a matrix
  7921. */
  7922. getBaseMatrix(): Matrix;
  7923. /**
  7924. * Gets the rest pose matrix
  7925. * @returns a matrix
  7926. */
  7927. getRestPose(): Matrix;
  7928. /**
  7929. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7930. */
  7931. getWorldMatrix(): Matrix;
  7932. /**
  7933. * Sets the local matrix to rest pose matrix
  7934. */
  7935. returnToRest(): void;
  7936. /**
  7937. * Gets the inverse of the absolute transform matrix.
  7938. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7939. * @returns a matrix
  7940. */
  7941. getInvertedAbsoluteTransform(): Matrix;
  7942. /**
  7943. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  7944. * @returns a matrix
  7945. */
  7946. getAbsoluteTransform(): Matrix;
  7947. /**
  7948. * Links with the given transform node.
  7949. * The local matrix of this bone is copied from the transform node every frame.
  7950. * @param transformNode defines the transform node to link to
  7951. */
  7952. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  7953. /** Gets or sets current position (in local space) */
  7954. position: Vector3;
  7955. /** Gets or sets current rotation (in local space) */
  7956. rotation: Vector3;
  7957. /** Gets or sets current rotation quaternion (in local space) */
  7958. rotationQuaternion: Quaternion;
  7959. /** Gets or sets current scaling (in local space) */
  7960. scaling: Vector3;
  7961. /**
  7962. * Gets the animation properties override
  7963. */
  7964. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  7965. private _decompose;
  7966. private _compose;
  7967. /**
  7968. * Update the base and local matrices
  7969. * @param matrix defines the new base or local matrix
  7970. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7971. * @param updateLocalMatrix defines if the local matrix should be updated
  7972. */
  7973. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  7974. /** @hidden */ updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  7975. /**
  7976. * Flag the bone as dirty (Forcing it to update everything)
  7977. */
  7978. markAsDirty(): void;
  7979. private _markAsDirtyAndCompose;
  7980. private _markAsDirtyAndDecompose;
  7981. /**
  7982. * Translate the bone in local or world space
  7983. * @param vec The amount to translate the bone
  7984. * @param space The space that the translation is in
  7985. * @param mesh The mesh that this bone is attached to. This is only used in world space
  7986. */
  7987. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  7988. /**
  7989. * Set the postion of the bone in local or world space
  7990. * @param position The position to set the bone
  7991. * @param space The space that the position is in
  7992. * @param mesh The mesh that this bone is attached to. This is only used in world space
  7993. */
  7994. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  7995. /**
  7996. * Set the absolute position of the bone (world space)
  7997. * @param position The position to set the bone
  7998. * @param mesh The mesh that this bone is attached to
  7999. */
  8000. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8001. /**
  8002. * Scale the bone on the x, y and z axes (in local space)
  8003. * @param x The amount to scale the bone on the x axis
  8004. * @param y The amount to scale the bone on the y axis
  8005. * @param z The amount to scale the bone on the z axis
  8006. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8007. */
  8008. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8009. /**
  8010. * Set the bone scaling in local space
  8011. * @param scale defines the scaling vector
  8012. */
  8013. setScale(scale: Vector3): void;
  8014. /**
  8015. * Gets the current scaling in local space
  8016. * @returns the current scaling vector
  8017. */
  8018. getScale(): Vector3;
  8019. /**
  8020. * Gets the current scaling in local space and stores it in a target vector
  8021. * @param result defines the target vector
  8022. */
  8023. getScaleToRef(result: Vector3): void;
  8024. /**
  8025. * Set the yaw, pitch, and roll of the bone in local or world space
  8026. * @param yaw The rotation of the bone on the y axis
  8027. * @param pitch The rotation of the bone on the x axis
  8028. * @param roll The rotation of the bone on the z axis
  8029. * @param space The space that the axes of rotation are in
  8030. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8031. */
  8032. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8033. /**
  8034. * Add a rotation to the bone on an axis in local or world space
  8035. * @param axis The axis to rotate the bone on
  8036. * @param amount The amount to rotate the bone
  8037. * @param space The space that the axis is in
  8038. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8039. */
  8040. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8041. /**
  8042. * Set the rotation of the bone to a particular axis angle in local or world space
  8043. * @param axis The axis to rotate the bone on
  8044. * @param angle The angle that the bone should be rotated to
  8045. * @param space The space that the axis is in
  8046. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8047. */
  8048. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8049. /**
  8050. * Set the euler rotation of the bone in local of world space
  8051. * @param rotation The euler rotation that the bone should be set to
  8052. * @param space The space that the rotation is in
  8053. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8054. */
  8055. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8056. /**
  8057. * Set the quaternion rotation of the bone in local of world space
  8058. * @param quat The quaternion rotation that the bone should be set to
  8059. * @param space The space that the rotation is in
  8060. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8061. */
  8062. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8063. /**
  8064. * Set the rotation matrix of the bone in local of world space
  8065. * @param rotMat The rotation matrix that the bone should be set to
  8066. * @param space The space that the rotation is in
  8067. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8068. */
  8069. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8070. private _rotateWithMatrix;
  8071. private _getNegativeRotationToRef;
  8072. /**
  8073. * Get the position of the bone in local or world space
  8074. * @param space The space that the returned position is in
  8075. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8076. * @returns The position of the bone
  8077. */
  8078. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8079. /**
  8080. * Copy the position of the bone to a vector3 in local or world space
  8081. * @param space The space that the returned position is in
  8082. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8083. * @param result The vector3 to copy the position to
  8084. */
  8085. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8086. /**
  8087. * Get the absolute position of the bone (world space)
  8088. * @param mesh The mesh that this bone is attached to
  8089. * @returns The absolute position of the bone
  8090. */
  8091. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8092. /**
  8093. * Copy the absolute position of the bone (world space) to the result param
  8094. * @param mesh The mesh that this bone is attached to
  8095. * @param result The vector3 to copy the absolute position to
  8096. */
  8097. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8098. /**
  8099. * Compute the absolute transforms of this bone and its children
  8100. */
  8101. computeAbsoluteTransforms(): void;
  8102. /**
  8103. * Get the world direction from an axis that is in the local space of the bone
  8104. * @param localAxis The local direction that is used to compute the world direction
  8105. * @param mesh The mesh that this bone is attached to
  8106. * @returns The world direction
  8107. */
  8108. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8109. /**
  8110. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8111. * @param localAxis The local direction that is used to compute the world direction
  8112. * @param mesh The mesh that this bone is attached to
  8113. * @param result The vector3 that the world direction will be copied to
  8114. */
  8115. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8116. /**
  8117. * Get the euler rotation of the bone in local or world space
  8118. * @param space The space that the rotation should be in
  8119. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8120. * @returns The euler rotation
  8121. */
  8122. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8123. /**
  8124. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8125. * @param space The space that the rotation should be in
  8126. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8127. * @param result The vector3 that the rotation should be copied to
  8128. */
  8129. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8130. /**
  8131. * Get the quaternion rotation of the bone in either local or world space
  8132. * @param space The space that the rotation should be in
  8133. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8134. * @returns The quaternion rotation
  8135. */
  8136. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8137. /**
  8138. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8139. * @param space The space that the rotation should be in
  8140. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8141. * @param result The quaternion that the rotation should be copied to
  8142. */
  8143. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8144. /**
  8145. * Get the rotation matrix of the bone in local or world space
  8146. * @param space The space that the rotation should be in
  8147. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8148. * @returns The rotation matrix
  8149. */
  8150. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8151. /**
  8152. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8153. * @param space The space that the rotation should be in
  8154. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8155. * @param result The quaternion that the rotation should be copied to
  8156. */
  8157. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8158. /**
  8159. * Get the world position of a point that is in the local space of the bone
  8160. * @param position The local position
  8161. * @param mesh The mesh that this bone is attached to
  8162. * @returns The world position
  8163. */
  8164. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8165. /**
  8166. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8167. * @param position The local position
  8168. * @param mesh The mesh that this bone is attached to
  8169. * @param result The vector3 that the world position should be copied to
  8170. */
  8171. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8172. /**
  8173. * Get the local position of a point that is in world space
  8174. * @param position The world position
  8175. * @param mesh The mesh that this bone is attached to
  8176. * @returns The local position
  8177. */
  8178. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8179. /**
  8180. * Get the local position of a point that is in world space and copy it to the result param
  8181. * @param position The world position
  8182. * @param mesh The mesh that this bone is attached to
  8183. * @param result The vector3 that the local position should be copied to
  8184. */
  8185. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8186. }
  8187. }
  8188. declare module BABYLON {
  8189. /**
  8190. * Enum that determines the text-wrapping mode to use.
  8191. */
  8192. export enum InspectableType {
  8193. /**
  8194. * Checkbox for booleans
  8195. */
  8196. Checkbox = 0,
  8197. /**
  8198. * Sliders for numbers
  8199. */
  8200. Slider = 1,
  8201. /**
  8202. * Vector3
  8203. */
  8204. Vector3 = 2,
  8205. /**
  8206. * Quaternions
  8207. */
  8208. Quaternion = 3,
  8209. /**
  8210. * Color3
  8211. */
  8212. Color3 = 4
  8213. }
  8214. /**
  8215. * Interface used to define custom inspectable properties.
  8216. * This interface is used by the inspector to display custom property grids
  8217. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8218. */
  8219. export interface IInspectable {
  8220. /**
  8221. * Gets the label to display
  8222. */
  8223. label: string;
  8224. /**
  8225. * Gets the name of the property to edit
  8226. */
  8227. propertyName: string;
  8228. /**
  8229. * Gets the type of the editor to use
  8230. */
  8231. type: InspectableType;
  8232. /**
  8233. * Gets the minimum value of the property when using in "slider" mode
  8234. */
  8235. min?: number;
  8236. /**
  8237. * Gets the maximum value of the property when using in "slider" mode
  8238. */
  8239. max?: number;
  8240. /**
  8241. * Gets the setp to use when using in "slider" mode
  8242. */
  8243. step?: number;
  8244. }
  8245. }
  8246. declare module BABYLON {
  8247. /**
  8248. * Class for creating a cube texture
  8249. */
  8250. export class CubeTexture extends BaseTexture {
  8251. private _delayedOnLoad;
  8252. /**
  8253. * The url of the texture
  8254. */
  8255. url: string;
  8256. /**
  8257. * Gets or sets the center of the bounding box associated with the cube texture.
  8258. * It must define where the camera used to render the texture was set
  8259. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8260. */
  8261. boundingBoxPosition: Vector3;
  8262. private _boundingBoxSize;
  8263. /**
  8264. * Gets or sets the size of the bounding box associated with the cube texture
  8265. * When defined, the cubemap will switch to local mode
  8266. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8267. * @example https://www.babylonjs-playground.com/#RNASML
  8268. */
  8269. /**
  8270. * Returns the bounding box size
  8271. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8272. */
  8273. boundingBoxSize: Vector3;
  8274. protected _rotationY: number;
  8275. /**
  8276. * Sets texture matrix rotation angle around Y axis in radians.
  8277. */
  8278. /**
  8279. * Gets texture matrix rotation angle around Y axis radians.
  8280. */
  8281. rotationY: number;
  8282. /**
  8283. * Are mip maps generated for this texture or not.
  8284. */
  8285. readonly noMipmap: boolean;
  8286. private _noMipmap;
  8287. private _files;
  8288. private _extensions;
  8289. private _textureMatrix;
  8290. private _format;
  8291. private _createPolynomials;
  8292. /** @hidden */ prefiltered: boolean;
  8293. /**
  8294. * Creates a cube texture from an array of image urls
  8295. * @param files defines an array of image urls
  8296. * @param scene defines the hosting scene
  8297. * @param noMipmap specifies if mip maps are not used
  8298. * @returns a cube texture
  8299. */
  8300. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8301. /**
  8302. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8303. * @param url defines the url of the prefiltered texture
  8304. * @param scene defines the scene the texture is attached to
  8305. * @param forcedExtension defines the extension of the file if different from the url
  8306. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8307. * @return the prefiltered texture
  8308. */
  8309. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8310. /**
  8311. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8312. * as prefiltered data.
  8313. * @param rootUrl defines the url of the texture or the root name of the six images
  8314. * @param scene defines the scene the texture is attached to
  8315. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8316. * @param noMipmap defines if mipmaps should be created or not
  8317. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8318. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8319. * @param onError defines a callback triggered in case of error during load
  8320. * @param format defines the internal format to use for the texture once loaded
  8321. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8322. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8323. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8324. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8325. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8326. * @return the cube texture
  8327. */
  8328. 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);
  8329. /**
  8330. * Get the current class name of the texture useful for serialization or dynamic coding.
  8331. * @returns "CubeTexture"
  8332. */
  8333. getClassName(): string;
  8334. /**
  8335. * Update the url (and optional buffer) of this texture if url was null during construction.
  8336. * @param url the url of the texture
  8337. * @param forcedExtension defines the extension to use
  8338. * @param onLoad callback called when the texture is loaded (defaults to null)
  8339. */
  8340. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8341. /**
  8342. * Delays loading of the cube texture
  8343. * @param forcedExtension defines the extension to use
  8344. */
  8345. delayLoad(forcedExtension?: string): void;
  8346. /**
  8347. * Returns the reflection texture matrix
  8348. * @returns the reflection texture matrix
  8349. */
  8350. getReflectionTextureMatrix(): Matrix;
  8351. /**
  8352. * Sets the reflection texture matrix
  8353. * @param value Reflection texture matrix
  8354. */
  8355. setReflectionTextureMatrix(value: Matrix): void;
  8356. /**
  8357. * Parses text to create a cube texture
  8358. * @param parsedTexture define the serialized text to read from
  8359. * @param scene defines the hosting scene
  8360. * @param rootUrl defines the root url of the cube texture
  8361. * @returns a cube texture
  8362. */
  8363. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8364. /**
  8365. * Makes a clone, or deep copy, of the cube texture
  8366. * @returns a new cube texture
  8367. */
  8368. clone(): CubeTexture;
  8369. }
  8370. }
  8371. declare module BABYLON {
  8372. /** @hidden */
  8373. export var postprocessVertexShader: {
  8374. name: string;
  8375. shader: string;
  8376. };
  8377. }
  8378. declare module BABYLON {
  8379. /**
  8380. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8381. * This is the base of the follow, arc rotate cameras and Free camera
  8382. * @see http://doc.babylonjs.com/features/cameras
  8383. */
  8384. export class TargetCamera extends Camera {
  8385. private static _RigCamTransformMatrix;
  8386. private static _TargetTransformMatrix;
  8387. private static _TargetFocalPoint;
  8388. /**
  8389. * Define the current direction the camera is moving to
  8390. */
  8391. cameraDirection: Vector3;
  8392. /**
  8393. * Define the current rotation the camera is rotating to
  8394. */
  8395. cameraRotation: Vector2;
  8396. /**
  8397. * When set, the up vector of the camera will be updated by the rotation of the camera
  8398. */
  8399. updateUpVectorFromRotation: boolean;
  8400. private _tmpQuaternion;
  8401. /**
  8402. * Define the current rotation of the camera
  8403. */
  8404. rotation: Vector3;
  8405. /**
  8406. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8407. */
  8408. rotationQuaternion: Quaternion;
  8409. /**
  8410. * Define the current speed of the camera
  8411. */
  8412. speed: number;
  8413. /**
  8414. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8415. * around all axis.
  8416. */
  8417. noRotationConstraint: boolean;
  8418. /**
  8419. * Define the current target of the camera as an object or a position.
  8420. */
  8421. lockedTarget: any;
  8422. /** @hidden */ currentTarget: Vector3;
  8423. /** @hidden */ initialFocalDistance: number;
  8424. /** @hidden */ viewMatrix: Matrix;
  8425. /** @hidden */ camMatrix: Matrix;
  8426. /** @hidden */ cameraTransformMatrix: Matrix;
  8427. /** @hidden */ cameraRotationMatrix: Matrix;
  8428. /** @hidden */ referencePoint: Vector3;
  8429. /** @hidden */ transformedReferencePoint: Vector3;
  8430. protected _globalCurrentTarget: Vector3;
  8431. protected _globalCurrentUpVector: Vector3;
  8432. /** @hidden */ reset: () => void;
  8433. private _defaultUp;
  8434. /**
  8435. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8436. * This is the base of the follow, arc rotate cameras and Free camera
  8437. * @see http://doc.babylonjs.com/features/cameras
  8438. * @param name Defines the name of the camera in the scene
  8439. * @param position Defines the start position of the camera in the scene
  8440. * @param scene Defines the scene the camera belongs to
  8441. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8442. */
  8443. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8444. /**
  8445. * Gets the position in front of the camera at a given distance.
  8446. * @param distance The distance from the camera we want the position to be
  8447. * @returns the position
  8448. */
  8449. getFrontPosition(distance: number): Vector3;
  8450. /** @hidden */ getLockedTargetPosition(): Nullable<Vector3>;
  8451. private _storedPosition;
  8452. private _storedRotation;
  8453. private _storedRotationQuaternion;
  8454. /**
  8455. * Store current camera state of the camera (fov, position, rotation, etc..)
  8456. * @returns the camera
  8457. */
  8458. storeState(): Camera;
  8459. /**
  8460. * Restored camera state. You must call storeState() first
  8461. * @returns whether it was successful or not
  8462. * @hidden
  8463. */ restoreStateValues(): boolean;
  8464. /** @hidden */ initCache(): void;
  8465. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  8466. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  8467. /** @hidden */ computeLocalCameraSpeed(): number;
  8468. /**
  8469. * Defines the target the camera should look at.
  8470. * This will automatically adapt alpha beta and radius to fit within the new target.
  8471. * @param target Defines the new target as a Vector or a mesh
  8472. */
  8473. setTarget(target: Vector3): void;
  8474. /**
  8475. * Return the current target position of the camera. This value is expressed in local space.
  8476. * @returns the target position
  8477. */
  8478. getTarget(): Vector3;
  8479. /** @hidden */ decideIfNeedsToMove(): boolean;
  8480. /** @hidden */ updatePosition(): void;
  8481. /** @hidden */ checkInputs(): void;
  8482. protected _updateCameraRotationMatrix(): void;
  8483. /**
  8484. * 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)
  8485. * @returns the current camera
  8486. */
  8487. private _rotateUpVectorWithCameraRotationMatrix;
  8488. private _cachedRotationZ;
  8489. private _cachedQuaternionRotationZ;
  8490. /** @hidden */ getViewMatrix(): Matrix;
  8491. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8492. /**
  8493. * @hidden
  8494. */
  8495. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8496. /**
  8497. * @hidden
  8498. */ updateRigCameras(): void;
  8499. private _getRigCamPositionAndTarget;
  8500. /**
  8501. * Gets the current object class name.
  8502. * @return the class name
  8503. */
  8504. getClassName(): string;
  8505. }
  8506. }
  8507. declare module BABYLON {
  8508. /**
  8509. * @ignore
  8510. * This is a list of all the different input types that are available in the application.
  8511. * Fo instance: ArcRotateCameraGamepadInput...
  8512. */
  8513. export var CameraInputTypes: {};
  8514. /**
  8515. * This is the contract to implement in order to create a new input class.
  8516. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8517. */
  8518. export interface ICameraInput<TCamera extends Camera> {
  8519. /**
  8520. * Defines the camera the input is attached to.
  8521. */
  8522. camera: Nullable<TCamera>;
  8523. /**
  8524. * Gets the class name of the current intput.
  8525. * @returns the class name
  8526. */
  8527. getClassName(): string;
  8528. /**
  8529. * Get the friendly name associated with the input class.
  8530. * @returns the input friendly name
  8531. */
  8532. getSimpleName(): string;
  8533. /**
  8534. * Attach the input controls to a specific dom element to get the input from.
  8535. * @param element Defines the element the controls should be listened from
  8536. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8537. */
  8538. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8539. /**
  8540. * Detach the current controls from the specified dom element.
  8541. * @param element Defines the element to stop listening the inputs from
  8542. */
  8543. detachControl(element: Nullable<HTMLElement>): void;
  8544. /**
  8545. * Update the current camera state depending on the inputs that have been used this frame.
  8546. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8547. */
  8548. checkInputs?: () => void;
  8549. }
  8550. /**
  8551. * Represents a map of input types to input instance or input index to input instance.
  8552. */
  8553. export interface CameraInputsMap<TCamera extends Camera> {
  8554. /**
  8555. * Accessor to the input by input type.
  8556. */
  8557. [name: string]: ICameraInput<TCamera>;
  8558. /**
  8559. * Accessor to the input by input index.
  8560. */
  8561. [idx: number]: ICameraInput<TCamera>;
  8562. }
  8563. /**
  8564. * This represents the input manager used within a camera.
  8565. * It helps dealing with all the different kind of input attached to a camera.
  8566. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8567. */
  8568. export class CameraInputsManager<TCamera extends Camera> {
  8569. /**
  8570. * Defines the list of inputs attahed to the camera.
  8571. */
  8572. attached: CameraInputsMap<TCamera>;
  8573. /**
  8574. * Defines the dom element the camera is collecting inputs from.
  8575. * This is null if the controls have not been attached.
  8576. */
  8577. attachedElement: Nullable<HTMLElement>;
  8578. /**
  8579. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8580. */
  8581. noPreventDefault: boolean;
  8582. /**
  8583. * Defined the camera the input manager belongs to.
  8584. */
  8585. camera: TCamera;
  8586. /**
  8587. * Update the current camera state depending on the inputs that have been used this frame.
  8588. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8589. */
  8590. checkInputs: () => void;
  8591. /**
  8592. * Instantiate a new Camera Input Manager.
  8593. * @param camera Defines the camera the input manager blongs to
  8594. */
  8595. constructor(camera: TCamera);
  8596. /**
  8597. * Add an input method to a camera
  8598. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8599. * @param input camera input method
  8600. */
  8601. add(input: ICameraInput<TCamera>): void;
  8602. /**
  8603. * Remove a specific input method from a camera
  8604. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8605. * @param inputToRemove camera input method
  8606. */
  8607. remove(inputToRemove: ICameraInput<TCamera>): void;
  8608. /**
  8609. * Remove a specific input type from a camera
  8610. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8611. * @param inputType the type of the input to remove
  8612. */
  8613. removeByType(inputType: string): void;
  8614. private _addCheckInputs;
  8615. /**
  8616. * Attach the input controls to the currently attached dom element to listen the events from.
  8617. * @param input Defines the input to attach
  8618. */
  8619. attachInput(input: ICameraInput<TCamera>): void;
  8620. /**
  8621. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8622. * @param element Defines the dom element to collect the events from
  8623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8624. */
  8625. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8626. /**
  8627. * Detach the current manager inputs controls from a specific dom element.
  8628. * @param element Defines the dom element to collect the events from
  8629. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8630. */
  8631. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8632. /**
  8633. * Rebuild the dynamic inputCheck function from the current list of
  8634. * defined inputs in the manager.
  8635. */
  8636. rebuildInputCheck(): void;
  8637. /**
  8638. * Remove all attached input methods from a camera
  8639. */
  8640. clear(): void;
  8641. /**
  8642. * Serialize the current input manager attached to a camera.
  8643. * This ensures than once parsed,
  8644. * the input associated to the camera will be identical to the current ones
  8645. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8646. */
  8647. serialize(serializedCamera: any): void;
  8648. /**
  8649. * Parses an input manager serialized JSON to restore the previous list of inputs
  8650. * and states associated to a camera.
  8651. * @param parsedCamera Defines the JSON to parse
  8652. */
  8653. parse(parsedCamera: any): void;
  8654. }
  8655. }
  8656. declare module BABYLON {
  8657. /**
  8658. * Gather the list of keyboard event types as constants.
  8659. */
  8660. export class KeyboardEventTypes {
  8661. /**
  8662. * The keydown event is fired when a key becomes active (pressed).
  8663. */
  8664. static readonly KEYDOWN: number;
  8665. /**
  8666. * The keyup event is fired when a key has been released.
  8667. */
  8668. static readonly KEYUP: number;
  8669. }
  8670. /**
  8671. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8672. */
  8673. export class KeyboardInfo {
  8674. /**
  8675. * Defines the type of event (KeyboardEventTypes)
  8676. */
  8677. type: number;
  8678. /**
  8679. * Defines the related dom event
  8680. */
  8681. event: KeyboardEvent;
  8682. /**
  8683. * Instantiates a new keyboard info.
  8684. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8685. * @param type Defines the type of event (KeyboardEventTypes)
  8686. * @param event Defines the related dom event
  8687. */
  8688. constructor(
  8689. /**
  8690. * Defines the type of event (KeyboardEventTypes)
  8691. */
  8692. type: number,
  8693. /**
  8694. * Defines the related dom event
  8695. */
  8696. event: KeyboardEvent);
  8697. }
  8698. /**
  8699. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8700. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8701. */
  8702. export class KeyboardInfoPre extends KeyboardInfo {
  8703. /**
  8704. * Defines the type of event (KeyboardEventTypes)
  8705. */
  8706. type: number;
  8707. /**
  8708. * Defines the related dom event
  8709. */
  8710. event: KeyboardEvent;
  8711. /**
  8712. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8713. */
  8714. skipOnPointerObservable: boolean;
  8715. /**
  8716. * Instantiates a new keyboard pre info.
  8717. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8718. * @param type Defines the type of event (KeyboardEventTypes)
  8719. * @param event Defines the related dom event
  8720. */
  8721. constructor(
  8722. /**
  8723. * Defines the type of event (KeyboardEventTypes)
  8724. */
  8725. type: number,
  8726. /**
  8727. * Defines the related dom event
  8728. */
  8729. event: KeyboardEvent);
  8730. }
  8731. }
  8732. declare module BABYLON {
  8733. /**
  8734. * Manage the keyboard inputs to control the movement of a free camera.
  8735. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8736. */
  8737. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8738. /**
  8739. * Defines the camera the input is attached to.
  8740. */
  8741. camera: FreeCamera;
  8742. /**
  8743. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8744. */
  8745. keysUp: number[];
  8746. /**
  8747. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8748. */
  8749. keysDown: number[];
  8750. /**
  8751. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8752. */
  8753. keysLeft: number[];
  8754. /**
  8755. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8756. */
  8757. keysRight: number[];
  8758. private _keys;
  8759. private _onCanvasBlurObserver;
  8760. private _onKeyboardObserver;
  8761. private _engine;
  8762. private _scene;
  8763. /**
  8764. * Attach the input controls to a specific dom element to get the input from.
  8765. * @param element Defines the element the controls should be listened from
  8766. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8767. */
  8768. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8769. /**
  8770. * Detach the current controls from the specified dom element.
  8771. * @param element Defines the element to stop listening the inputs from
  8772. */
  8773. detachControl(element: Nullable<HTMLElement>): void;
  8774. /**
  8775. * Update the current camera state depending on the inputs that have been used this frame.
  8776. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8777. */
  8778. checkInputs(): void;
  8779. /**
  8780. * Gets the class name of the current intput.
  8781. * @returns the class name
  8782. */
  8783. getClassName(): string;
  8784. /** @hidden */ onLostFocus(): void;
  8785. /**
  8786. * Get the friendly name associated with the input class.
  8787. * @returns the input friendly name
  8788. */
  8789. getSimpleName(): string;
  8790. }
  8791. }
  8792. declare module BABYLON {
  8793. /**
  8794. * Interface describing all the common properties and methods a shadow light needs to implement.
  8795. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8796. * as well as binding the different shadow properties to the effects.
  8797. */
  8798. export interface IShadowLight extends Light {
  8799. /**
  8800. * The light id in the scene (used in scene.findLighById for instance)
  8801. */
  8802. id: string;
  8803. /**
  8804. * The position the shdow will be casted from.
  8805. */
  8806. position: Vector3;
  8807. /**
  8808. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8809. */
  8810. direction: Vector3;
  8811. /**
  8812. * The transformed position. Position of the light in world space taking parenting in account.
  8813. */
  8814. transformedPosition: Vector3;
  8815. /**
  8816. * The transformed direction. Direction of the light in world space taking parenting in account.
  8817. */
  8818. transformedDirection: Vector3;
  8819. /**
  8820. * The friendly name of the light in the scene.
  8821. */
  8822. name: string;
  8823. /**
  8824. * Defines the shadow projection clipping minimum z value.
  8825. */
  8826. shadowMinZ: number;
  8827. /**
  8828. * Defines the shadow projection clipping maximum z value.
  8829. */
  8830. shadowMaxZ: number;
  8831. /**
  8832. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8833. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8834. */
  8835. computeTransformedInformation(): boolean;
  8836. /**
  8837. * Gets the scene the light belongs to.
  8838. * @returns The scene
  8839. */
  8840. getScene(): Scene;
  8841. /**
  8842. * Callback defining a custom Projection Matrix Builder.
  8843. * This can be used to override the default projection matrix computation.
  8844. */
  8845. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8846. /**
  8847. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8848. * @param matrix The materix to updated with the projection information
  8849. * @param viewMatrix The transform matrix of the light
  8850. * @param renderList The list of mesh to render in the map
  8851. * @returns The current light
  8852. */
  8853. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8854. /**
  8855. * Gets the current depth scale used in ESM.
  8856. * @returns The scale
  8857. */
  8858. getDepthScale(): number;
  8859. /**
  8860. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8861. * @returns true if a cube texture needs to be use
  8862. */
  8863. needCube(): boolean;
  8864. /**
  8865. * Detects if the projection matrix requires to be recomputed this frame.
  8866. * @returns true if it requires to be recomputed otherwise, false.
  8867. */
  8868. needProjectionMatrixCompute(): boolean;
  8869. /**
  8870. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8871. */
  8872. forceProjectionMatrixCompute(): void;
  8873. /**
  8874. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8875. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8876. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8877. */
  8878. getShadowDirection(faceIndex?: number): Vector3;
  8879. /**
  8880. * Gets the minZ used for shadow according to both the scene and the light.
  8881. * @param activeCamera The camera we are returning the min for
  8882. * @returns the depth min z
  8883. */
  8884. getDepthMinZ(activeCamera: Camera): number;
  8885. /**
  8886. * Gets the maxZ used for shadow according to both the scene and the light.
  8887. * @param activeCamera The camera we are returning the max for
  8888. * @returns the depth max z
  8889. */
  8890. getDepthMaxZ(activeCamera: Camera): number;
  8891. }
  8892. /**
  8893. * Base implementation IShadowLight
  8894. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8895. */
  8896. export abstract class ShadowLight extends Light implements IShadowLight {
  8897. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8898. protected _position: Vector3;
  8899. protected _setPosition(value: Vector3): void;
  8900. /**
  8901. * Sets the position the shadow will be casted from. Also use as the light position for both
  8902. * point and spot lights.
  8903. */
  8904. /**
  8905. * Sets the position the shadow will be casted from. Also use as the light position for both
  8906. * point and spot lights.
  8907. */
  8908. position: Vector3;
  8909. protected _direction: Vector3;
  8910. protected _setDirection(value: Vector3): void;
  8911. /**
  8912. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8913. * Also use as the light direction on spot and directional lights.
  8914. */
  8915. /**
  8916. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8917. * Also use as the light direction on spot and directional lights.
  8918. */
  8919. direction: Vector3;
  8920. private _shadowMinZ;
  8921. /**
  8922. * Gets the shadow projection clipping minimum z value.
  8923. */
  8924. /**
  8925. * Sets the shadow projection clipping minimum z value.
  8926. */
  8927. shadowMinZ: number;
  8928. private _shadowMaxZ;
  8929. /**
  8930. * Sets the shadow projection clipping maximum z value.
  8931. */
  8932. /**
  8933. * Gets the shadow projection clipping maximum z value.
  8934. */
  8935. shadowMaxZ: number;
  8936. /**
  8937. * Callback defining a custom Projection Matrix Builder.
  8938. * This can be used to override the default projection matrix computation.
  8939. */
  8940. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8941. /**
  8942. * The transformed position. Position of the light in world space taking parenting in account.
  8943. */
  8944. transformedPosition: Vector3;
  8945. /**
  8946. * The transformed direction. Direction of the light in world space taking parenting in account.
  8947. */
  8948. transformedDirection: Vector3;
  8949. private _needProjectionMatrixCompute;
  8950. /**
  8951. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8952. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8953. */
  8954. computeTransformedInformation(): boolean;
  8955. /**
  8956. * Return the depth scale used for the shadow map.
  8957. * @returns the depth scale.
  8958. */
  8959. getDepthScale(): number;
  8960. /**
  8961. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8962. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8963. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8964. */
  8965. getShadowDirection(faceIndex?: number): Vector3;
  8966. /**
  8967. * Returns the ShadowLight absolute position in the World.
  8968. * @returns the position vector in world space
  8969. */
  8970. getAbsolutePosition(): Vector3;
  8971. /**
  8972. * Sets the ShadowLight direction toward the passed target.
  8973. * @param target The point to target in local space
  8974. * @returns the updated ShadowLight direction
  8975. */
  8976. setDirectionToTarget(target: Vector3): Vector3;
  8977. /**
  8978. * Returns the light rotation in euler definition.
  8979. * @returns the x y z rotation in local space.
  8980. */
  8981. getRotation(): Vector3;
  8982. /**
  8983. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8984. * @returns true if a cube texture needs to be use
  8985. */
  8986. needCube(): boolean;
  8987. /**
  8988. * Detects if the projection matrix requires to be recomputed this frame.
  8989. * @returns true if it requires to be recomputed otherwise, false.
  8990. */
  8991. needProjectionMatrixCompute(): boolean;
  8992. /**
  8993. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8994. */
  8995. forceProjectionMatrixCompute(): void;
  8996. /** @hidden */ initCache(): void;
  8997. /** @hidden */ isSynchronized(): boolean;
  8998. /**
  8999. * Computes the world matrix of the node
  9000. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9001. * @returns the world matrix
  9002. */
  9003. computeWorldMatrix(force?: boolean): Matrix;
  9004. /**
  9005. * Gets the minZ used for shadow according to both the scene and the light.
  9006. * @param activeCamera The camera we are returning the min for
  9007. * @returns the depth min z
  9008. */
  9009. getDepthMinZ(activeCamera: Camera): number;
  9010. /**
  9011. * Gets the maxZ used for shadow according to both the scene and the light.
  9012. * @param activeCamera The camera we are returning the max for
  9013. * @returns the depth max z
  9014. */
  9015. getDepthMaxZ(activeCamera: Camera): number;
  9016. /**
  9017. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9018. * @param matrix The materix to updated with the projection information
  9019. * @param viewMatrix The transform matrix of the light
  9020. * @param renderList The list of mesh to render in the map
  9021. * @returns The current light
  9022. */
  9023. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9024. }
  9025. }
  9026. declare module BABYLON {
  9027. /**
  9028. * "Static Class" containing the most commonly used helper while dealing with material for
  9029. * rendering purpose.
  9030. *
  9031. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9032. *
  9033. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9034. */
  9035. export class MaterialHelper {
  9036. /**
  9037. * Bind the current view position to an effect.
  9038. * @param effect The effect to be bound
  9039. * @param scene The scene the eyes position is used from
  9040. */
  9041. static BindEyePosition(effect: Effect, scene: Scene): void;
  9042. /**
  9043. * Helps preparing the defines values about the UVs in used in the effect.
  9044. * UVs are shared as much as we can accross channels in the shaders.
  9045. * @param texture The texture we are preparing the UVs for
  9046. * @param defines The defines to update
  9047. * @param key The channel key "diffuse", "specular"... used in the shader
  9048. */
  9049. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9050. /**
  9051. * Binds a texture matrix value to its corrsponding uniform
  9052. * @param texture The texture to bind the matrix for
  9053. * @param uniformBuffer The uniform buffer receivin the data
  9054. * @param key The channel key "diffuse", "specular"... used in the shader
  9055. */
  9056. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9057. /**
  9058. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9059. * @param mesh defines the current mesh
  9060. * @param scene defines the current scene
  9061. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9062. * @param pointsCloud defines if point cloud rendering has to be turned on
  9063. * @param fogEnabled defines if fog has to be turned on
  9064. * @param alphaTest defines if alpha testing has to be turned on
  9065. * @param defines defines the current list of defines
  9066. */
  9067. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9068. /**
  9069. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9070. * @param scene defines the current scene
  9071. * @param engine defines the current engine
  9072. * @param defines specifies the list of active defines
  9073. * @param useInstances defines if instances have to be turned on
  9074. * @param useClipPlane defines if clip plane have to be turned on
  9075. */
  9076. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9077. /**
  9078. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9079. * @param mesh The mesh containing the geometry data we will draw
  9080. * @param defines The defines to update
  9081. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9082. * @param useBones Precise whether bones should be used or not (override mesh info)
  9083. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9084. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9085. * @returns false if defines are considered not dirty and have not been checked
  9086. */
  9087. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9088. /**
  9089. * Prepares the defines related to multiview
  9090. * @param scene The scene we are intending to draw
  9091. * @param defines The defines to update
  9092. */
  9093. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9094. /**
  9095. * Prepares the defines related to the light information passed in parameter
  9096. * @param scene The scene we are intending to draw
  9097. * @param mesh The mesh the effect is compiling for
  9098. * @param defines The defines to update
  9099. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9100. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9101. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9102. * @returns true if normals will be required for the rest of the effect
  9103. */
  9104. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9105. /**
  9106. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9107. * that won t be acctive due to defines being turned off.
  9108. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9109. * @param samplersList The samplers list
  9110. * @param defines The defines helping in the list generation
  9111. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9112. */
  9113. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9114. /**
  9115. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9116. * @param defines The defines to update while falling back
  9117. * @param fallbacks The authorized effect fallbacks
  9118. * @param maxSimultaneousLights The maximum number of lights allowed
  9119. * @param rank the current rank of the Effect
  9120. * @returns The newly affected rank
  9121. */
  9122. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9123. /**
  9124. * Prepares the list of attributes required for morph targets according to the effect defines.
  9125. * @param attribs The current list of supported attribs
  9126. * @param mesh The mesh to prepare the morph targets attributes for
  9127. * @param defines The current Defines of the effect
  9128. */
  9129. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9130. /**
  9131. * Prepares the list of attributes required for bones according to the effect defines.
  9132. * @param attribs The current list of supported attribs
  9133. * @param mesh The mesh to prepare the bones attributes for
  9134. * @param defines The current Defines of the effect
  9135. * @param fallbacks The current efffect fallback strategy
  9136. */
  9137. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9138. /**
  9139. * Prepares the list of attributes required for instances according to the effect defines.
  9140. * @param attribs The current list of supported attribs
  9141. * @param defines The current Defines of the effect
  9142. */
  9143. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9144. /**
  9145. * Binds the light shadow information to the effect for the given mesh.
  9146. * @param light The light containing the generator
  9147. * @param scene The scene the lights belongs to
  9148. * @param mesh The mesh we are binding the information to render
  9149. * @param lightIndex The light index in the effect used to render the mesh
  9150. * @param effect The effect we are binding the data to
  9151. */
  9152. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9153. /**
  9154. * Binds the light information to the effect.
  9155. * @param light The light containing the generator
  9156. * @param effect The effect we are binding the data to
  9157. * @param lightIndex The light index in the effect used to render
  9158. */
  9159. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9160. /**
  9161. * Binds the lights information from the scene to the effect for the given mesh.
  9162. * @param scene The scene the lights belongs to
  9163. * @param mesh The mesh we are binding the information to render
  9164. * @param effect The effect we are binding the data to
  9165. * @param defines The generated defines for the effect
  9166. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9167. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9168. */
  9169. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9170. private static _tempFogColor;
  9171. /**
  9172. * Binds the fog information from the scene to the effect for the given mesh.
  9173. * @param scene The scene the lights belongs to
  9174. * @param mesh The mesh we are binding the information to render
  9175. * @param effect The effect we are binding the data to
  9176. * @param linearSpace Defines if the fog effect is applied in linear space
  9177. */
  9178. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9179. /**
  9180. * Binds the bones information from the mesh to the effect.
  9181. * @param mesh The mesh we are binding the information to render
  9182. * @param effect The effect we are binding the data to
  9183. */
  9184. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9185. /**
  9186. * Binds the morph targets information from the mesh to the effect.
  9187. * @param abstractMesh The mesh we are binding the information to render
  9188. * @param effect The effect we are binding the data to
  9189. */
  9190. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9191. /**
  9192. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9193. * @param defines The generated defines used in the effect
  9194. * @param effect The effect we are binding the data to
  9195. * @param scene The scene we are willing to render with logarithmic scale for
  9196. */
  9197. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9198. /**
  9199. * Binds the clip plane information from the scene to the effect.
  9200. * @param scene The scene the clip plane information are extracted from
  9201. * @param effect The effect we are binding the data to
  9202. */
  9203. static BindClipPlane(effect: Effect, scene: Scene): void;
  9204. }
  9205. }
  9206. declare module BABYLON {
  9207. /** @hidden */
  9208. export var kernelBlurVaryingDeclaration: {
  9209. name: string;
  9210. shader: string;
  9211. };
  9212. }
  9213. declare module BABYLON {
  9214. /** @hidden */
  9215. export var kernelBlurFragment: {
  9216. name: string;
  9217. shader: string;
  9218. };
  9219. }
  9220. declare module BABYLON {
  9221. /** @hidden */
  9222. export var kernelBlurFragment2: {
  9223. name: string;
  9224. shader: string;
  9225. };
  9226. }
  9227. declare module BABYLON {
  9228. /** @hidden */
  9229. export var kernelBlurPixelShader: {
  9230. name: string;
  9231. shader: string;
  9232. };
  9233. }
  9234. declare module BABYLON {
  9235. /** @hidden */
  9236. export var kernelBlurVertex: {
  9237. name: string;
  9238. shader: string;
  9239. };
  9240. }
  9241. declare module BABYLON {
  9242. /** @hidden */
  9243. export var kernelBlurVertexShader: {
  9244. name: string;
  9245. shader: string;
  9246. };
  9247. }
  9248. declare module BABYLON {
  9249. /**
  9250. * The Blur Post Process which blurs an image based on a kernel and direction.
  9251. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9252. */
  9253. export class BlurPostProcess extends PostProcess {
  9254. /** The direction in which to blur the image. */
  9255. direction: Vector2;
  9256. private blockCompilation;
  9257. protected _kernel: number;
  9258. protected _idealKernel: number;
  9259. protected _packedFloat: boolean;
  9260. private _staticDefines;
  9261. /**
  9262. * Sets the length in pixels of the blur sample region
  9263. */
  9264. /**
  9265. * Gets the length in pixels of the blur sample region
  9266. */
  9267. kernel: number;
  9268. /**
  9269. * Sets wether or not the blur needs to unpack/repack floats
  9270. */
  9271. /**
  9272. * Gets wether or not the blur is unpacking/repacking floats
  9273. */
  9274. packedFloat: boolean;
  9275. /**
  9276. * Creates a new instance BlurPostProcess
  9277. * @param name The name of the effect.
  9278. * @param direction The direction in which to blur the image.
  9279. * @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.
  9280. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9281. * @param camera The camera to apply the render pass to.
  9282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9283. * @param engine The engine which the post process will be applied. (default: current engine)
  9284. * @param reusable If the post process can be reused on the same frame. (default: false)
  9285. * @param textureType Type of textures used when performing the post process. (default: 0)
  9286. * @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)
  9287. */
  9288. constructor(name: string,
  9289. /** The direction in which to blur the image. */
  9290. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9291. /**
  9292. * Updates the effect with the current post process compile time values and recompiles the shader.
  9293. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9294. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9295. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9296. * @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
  9297. * @param onCompiled Called when the shader has been compiled.
  9298. * @param onError Called if there is an error when compiling a shader.
  9299. */
  9300. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9301. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9302. /**
  9303. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9304. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9305. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9306. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9307. * The gaps between physical kernels are compensated for in the weighting of the samples
  9308. * @param idealKernel Ideal blur kernel.
  9309. * @return Nearest best kernel.
  9310. */
  9311. protected _nearestBestKernel(idealKernel: number): number;
  9312. /**
  9313. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9314. * @param x The point on the Gaussian distribution to sample.
  9315. * @return the value of the Gaussian function at x.
  9316. */
  9317. protected _gaussianWeight(x: number): number;
  9318. /**
  9319. * Generates a string that can be used as a floating point number in GLSL.
  9320. * @param x Value to print.
  9321. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9322. * @return GLSL float string.
  9323. */
  9324. protected _glslFloat(x: number, decimalFigures?: number): string;
  9325. }
  9326. }
  9327. declare module BABYLON {
  9328. /** @hidden */
  9329. export var shadowMapPixelShader: {
  9330. name: string;
  9331. shader: string;
  9332. };
  9333. }
  9334. declare module BABYLON {
  9335. /** @hidden */
  9336. export var bonesDeclaration: {
  9337. name: string;
  9338. shader: string;
  9339. };
  9340. }
  9341. declare module BABYLON {
  9342. /** @hidden */
  9343. export var morphTargetsVertexGlobalDeclaration: {
  9344. name: string;
  9345. shader: string;
  9346. };
  9347. }
  9348. declare module BABYLON {
  9349. /** @hidden */
  9350. export var morphTargetsVertexDeclaration: {
  9351. name: string;
  9352. shader: string;
  9353. };
  9354. }
  9355. declare module BABYLON {
  9356. /** @hidden */
  9357. export var instancesDeclaration: {
  9358. name: string;
  9359. shader: string;
  9360. };
  9361. }
  9362. declare module BABYLON {
  9363. /** @hidden */
  9364. export var helperFunctions: {
  9365. name: string;
  9366. shader: string;
  9367. };
  9368. }
  9369. declare module BABYLON {
  9370. /** @hidden */
  9371. export var morphTargetsVertex: {
  9372. name: string;
  9373. shader: string;
  9374. };
  9375. }
  9376. declare module BABYLON {
  9377. /** @hidden */
  9378. export var instancesVertex: {
  9379. name: string;
  9380. shader: string;
  9381. };
  9382. }
  9383. declare module BABYLON {
  9384. /** @hidden */
  9385. export var bonesVertex: {
  9386. name: string;
  9387. shader: string;
  9388. };
  9389. }
  9390. declare module BABYLON {
  9391. /** @hidden */
  9392. export var shadowMapVertexShader: {
  9393. name: string;
  9394. shader: string;
  9395. };
  9396. }
  9397. declare module BABYLON {
  9398. /** @hidden */
  9399. export var depthBoxBlurPixelShader: {
  9400. name: string;
  9401. shader: string;
  9402. };
  9403. }
  9404. declare module BABYLON {
  9405. /**
  9406. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9407. */
  9408. export interface ICustomShaderOptions {
  9409. /**
  9410. * Gets or sets the custom shader name to use
  9411. */
  9412. shaderName: string;
  9413. /**
  9414. * The list of attribute names used in the shader
  9415. */
  9416. attributes?: string[];
  9417. /**
  9418. * The list of unifrom names used in the shader
  9419. */
  9420. uniforms?: string[];
  9421. /**
  9422. * The list of sampler names used in the shader
  9423. */
  9424. samplers?: string[];
  9425. /**
  9426. * The list of defines used in the shader
  9427. */
  9428. defines?: string[];
  9429. }
  9430. /**
  9431. * Interface to implement to create a shadow generator compatible with BJS.
  9432. */
  9433. export interface IShadowGenerator {
  9434. /**
  9435. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9436. * @returns The render target texture if present otherwise, null
  9437. */
  9438. getShadowMap(): Nullable<RenderTargetTexture>;
  9439. /**
  9440. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9441. * @returns The render target texture if the shadow map is present otherwise, null
  9442. */
  9443. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9444. /**
  9445. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9446. * @param subMesh The submesh we want to render in the shadow map
  9447. * @param useInstances Defines wether will draw in the map using instances
  9448. * @returns true if ready otherwise, false
  9449. */
  9450. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9451. /**
  9452. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9453. * @param defines Defines of the material we want to update
  9454. * @param lightIndex Index of the light in the enabled light list of the material
  9455. */
  9456. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9457. /**
  9458. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9459. * defined in the generator but impacting the effect).
  9460. * It implies the unifroms available on the materials are the standard BJS ones.
  9461. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9462. * @param effect The effect we are binfing the information for
  9463. */
  9464. bindShadowLight(lightIndex: string, effect: Effect): void;
  9465. /**
  9466. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9467. * (eq to shadow prjection matrix * light transform matrix)
  9468. * @returns The transform matrix used to create the shadow map
  9469. */
  9470. getTransformMatrix(): Matrix;
  9471. /**
  9472. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9473. * Cube and 2D textures for instance.
  9474. */
  9475. recreateShadowMap(): void;
  9476. /**
  9477. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9478. * @param onCompiled Callback triggered at the and of the effects compilation
  9479. * @param options Sets of optional options forcing the compilation with different modes
  9480. */
  9481. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9482. useInstances: boolean;
  9483. }>): void;
  9484. /**
  9485. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9486. * @param options Sets of optional options forcing the compilation with different modes
  9487. * @returns A promise that resolves when the compilation completes
  9488. */
  9489. forceCompilationAsync(options?: Partial<{
  9490. useInstances: boolean;
  9491. }>): Promise<void>;
  9492. /**
  9493. * Serializes the shadow generator setup to a json object.
  9494. * @returns The serialized JSON object
  9495. */
  9496. serialize(): any;
  9497. /**
  9498. * Disposes the Shadow map and related Textures and effects.
  9499. */
  9500. dispose(): void;
  9501. }
  9502. /**
  9503. * Default implementation IShadowGenerator.
  9504. * This is the main object responsible of generating shadows in the framework.
  9505. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9506. */
  9507. export class ShadowGenerator implements IShadowGenerator {
  9508. /**
  9509. * Shadow generator mode None: no filtering applied.
  9510. */
  9511. static readonly FILTER_NONE: number;
  9512. /**
  9513. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9514. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9515. */
  9516. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9517. /**
  9518. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9519. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9520. */
  9521. static readonly FILTER_POISSONSAMPLING: number;
  9522. /**
  9523. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9524. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9525. */
  9526. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9527. /**
  9528. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9529. * edge artifacts on steep falloff.
  9530. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9531. */
  9532. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9533. /**
  9534. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9535. * edge artifacts on steep falloff.
  9536. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9537. */
  9538. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9539. /**
  9540. * Shadow generator mode PCF: Percentage Closer Filtering
  9541. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9542. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9543. */
  9544. static readonly FILTER_PCF: number;
  9545. /**
  9546. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9547. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9548. * Contact Hardening
  9549. */
  9550. static readonly FILTER_PCSS: number;
  9551. /**
  9552. * Reserved for PCF and PCSS
  9553. * Highest Quality.
  9554. *
  9555. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9556. *
  9557. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9558. */
  9559. static readonly QUALITY_HIGH: number;
  9560. /**
  9561. * Reserved for PCF and PCSS
  9562. * Good tradeoff for quality/perf cross devices
  9563. *
  9564. * Execute PCF on a 3*3 kernel.
  9565. *
  9566. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9567. */
  9568. static readonly QUALITY_MEDIUM: number;
  9569. /**
  9570. * Reserved for PCF and PCSS
  9571. * The lowest quality but the fastest.
  9572. *
  9573. * Execute PCF on a 1*1 kernel.
  9574. *
  9575. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9576. */
  9577. static readonly QUALITY_LOW: number;
  9578. /** Gets or sets the custom shader name to use */
  9579. customShaderOptions: ICustomShaderOptions;
  9580. /**
  9581. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9582. */
  9583. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9584. /**
  9585. * Observable triggered before a mesh is rendered in the shadow map.
  9586. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9587. */
  9588. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9589. private _bias;
  9590. /**
  9591. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9592. */
  9593. /**
  9594. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9595. */
  9596. bias: number;
  9597. private _normalBias;
  9598. /**
  9599. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9600. */
  9601. /**
  9602. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9603. */
  9604. normalBias: number;
  9605. private _blurBoxOffset;
  9606. /**
  9607. * Gets the blur box offset: offset applied during the blur pass.
  9608. * Only useful if useKernelBlur = false
  9609. */
  9610. /**
  9611. * Sets the blur box offset: offset applied during the blur pass.
  9612. * Only useful if useKernelBlur = false
  9613. */
  9614. blurBoxOffset: number;
  9615. private _blurScale;
  9616. /**
  9617. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9618. * 2 means half of the size.
  9619. */
  9620. /**
  9621. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9622. * 2 means half of the size.
  9623. */
  9624. blurScale: number;
  9625. private _blurKernel;
  9626. /**
  9627. * Gets the blur kernel: kernel size of the blur pass.
  9628. * Only useful if useKernelBlur = true
  9629. */
  9630. /**
  9631. * Sets the blur kernel: kernel size of the blur pass.
  9632. * Only useful if useKernelBlur = true
  9633. */
  9634. blurKernel: number;
  9635. private _useKernelBlur;
  9636. /**
  9637. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9638. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9639. */
  9640. /**
  9641. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9642. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9643. */
  9644. useKernelBlur: boolean;
  9645. private _depthScale;
  9646. /**
  9647. * Gets the depth scale used in ESM mode.
  9648. */
  9649. /**
  9650. * Sets the depth scale used in ESM mode.
  9651. * This can override the scale stored on the light.
  9652. */
  9653. depthScale: number;
  9654. private _filter;
  9655. /**
  9656. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9657. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9658. */
  9659. /**
  9660. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9661. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9662. */
  9663. filter: number;
  9664. /**
  9665. * Gets if the current filter is set to Poisson Sampling.
  9666. */
  9667. /**
  9668. * Sets the current filter to Poisson Sampling.
  9669. */
  9670. usePoissonSampling: boolean;
  9671. /**
  9672. * Gets if the current filter is set to ESM.
  9673. */
  9674. /**
  9675. * Sets the current filter is to ESM.
  9676. */
  9677. useExponentialShadowMap: boolean;
  9678. /**
  9679. * Gets if the current filter is set to filtered ESM.
  9680. */
  9681. /**
  9682. * Gets if the current filter is set to filtered ESM.
  9683. */
  9684. useBlurExponentialShadowMap: boolean;
  9685. /**
  9686. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9687. * exponential to prevent steep falloff artifacts).
  9688. */
  9689. /**
  9690. * Sets the current filter to "close ESM" (using the inverse of the
  9691. * exponential to prevent steep falloff artifacts).
  9692. */
  9693. useCloseExponentialShadowMap: boolean;
  9694. /**
  9695. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9696. * exponential to prevent steep falloff artifacts).
  9697. */
  9698. /**
  9699. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9700. * exponential to prevent steep falloff artifacts).
  9701. */
  9702. useBlurCloseExponentialShadowMap: boolean;
  9703. /**
  9704. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9705. */
  9706. /**
  9707. * Sets the current filter to "PCF" (percentage closer filtering).
  9708. */
  9709. usePercentageCloserFiltering: boolean;
  9710. private _filteringQuality;
  9711. /**
  9712. * Gets the PCF or PCSS Quality.
  9713. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9714. */
  9715. /**
  9716. * Sets the PCF or PCSS Quality.
  9717. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9718. */
  9719. filteringQuality: number;
  9720. /**
  9721. * Gets if the current filter is set to "PCSS" (contact hardening).
  9722. */
  9723. /**
  9724. * Sets the current filter to "PCSS" (contact hardening).
  9725. */
  9726. useContactHardeningShadow: boolean;
  9727. private _contactHardeningLightSizeUVRatio;
  9728. /**
  9729. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9730. * Using a ratio helps keeping shape stability independently of the map size.
  9731. *
  9732. * It does not account for the light projection as it was having too much
  9733. * instability during the light setup or during light position changes.
  9734. *
  9735. * Only valid if useContactHardeningShadow is true.
  9736. */
  9737. /**
  9738. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9739. * Using a ratio helps keeping shape stability independently of the map size.
  9740. *
  9741. * It does not account for the light projection as it was having too much
  9742. * instability during the light setup or during light position changes.
  9743. *
  9744. * Only valid if useContactHardeningShadow is true.
  9745. */
  9746. contactHardeningLightSizeUVRatio: number;
  9747. private _darkness;
  9748. /**
  9749. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9750. * 0 means strongest and 1 would means no shadow.
  9751. * @returns the darkness.
  9752. */
  9753. getDarkness(): number;
  9754. /**
  9755. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9756. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9757. * @returns the shadow generator allowing fluent coding.
  9758. */
  9759. setDarkness(darkness: number): ShadowGenerator;
  9760. private _transparencyShadow;
  9761. /**
  9762. * Sets the ability to have transparent shadow (boolean).
  9763. * @param transparent True if transparent else False
  9764. * @returns the shadow generator allowing fluent coding
  9765. */
  9766. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9767. private _shadowMap;
  9768. private _shadowMap2;
  9769. /**
  9770. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9771. * @returns The render target texture if present otherwise, null
  9772. */
  9773. getShadowMap(): Nullable<RenderTargetTexture>;
  9774. /**
  9775. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9776. * @returns The render target texture if the shadow map is present otherwise, null
  9777. */
  9778. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9779. /**
  9780. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9781. * @param mesh Mesh to add
  9782. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9783. * @returns the Shadow Generator itself
  9784. */
  9785. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9786. /**
  9787. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9788. * @param mesh Mesh to remove
  9789. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9790. * @returns the Shadow Generator itself
  9791. */
  9792. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9793. /**
  9794. * Controls the extent to which the shadows fade out at the edge of the frustum
  9795. * Used only by directionals and spots
  9796. */
  9797. frustumEdgeFalloff: number;
  9798. private _light;
  9799. /**
  9800. * Returns the associated light object.
  9801. * @returns the light generating the shadow
  9802. */
  9803. getLight(): IShadowLight;
  9804. /**
  9805. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9806. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9807. * It might on the other hand introduce peter panning.
  9808. */
  9809. forceBackFacesOnly: boolean;
  9810. private _scene;
  9811. private _lightDirection;
  9812. private _effect;
  9813. private _viewMatrix;
  9814. private _projectionMatrix;
  9815. private _transformMatrix;
  9816. private _cachedPosition;
  9817. private _cachedDirection;
  9818. private _cachedDefines;
  9819. private _currentRenderID;
  9820. private _boxBlurPostprocess;
  9821. private _kernelBlurXPostprocess;
  9822. private _kernelBlurYPostprocess;
  9823. private _blurPostProcesses;
  9824. private _mapSize;
  9825. private _currentFaceIndex;
  9826. private _currentFaceIndexCache;
  9827. private _textureType;
  9828. private _defaultTextureMatrix;
  9829. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9830. /**
  9831. * Creates a ShadowGenerator object.
  9832. * A ShadowGenerator is the required tool to use the shadows.
  9833. * Each light casting shadows needs to use its own ShadowGenerator.
  9834. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9835. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9836. * @param light The light object generating the shadows.
  9837. * @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.
  9838. */
  9839. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9840. private _initializeGenerator;
  9841. private _initializeShadowMap;
  9842. private _initializeBlurRTTAndPostProcesses;
  9843. private _renderForShadowMap;
  9844. private _renderSubMeshForShadowMap;
  9845. private _applyFilterValues;
  9846. /**
  9847. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9848. * @param onCompiled Callback triggered at the and of the effects compilation
  9849. * @param options Sets of optional options forcing the compilation with different modes
  9850. */
  9851. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9852. useInstances: boolean;
  9853. }>): void;
  9854. /**
  9855. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9856. * @param options Sets of optional options forcing the compilation with different modes
  9857. * @returns A promise that resolves when the compilation completes
  9858. */
  9859. forceCompilationAsync(options?: Partial<{
  9860. useInstances: boolean;
  9861. }>): Promise<void>;
  9862. /**
  9863. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9864. * @param subMesh The submesh we want to render in the shadow map
  9865. * @param useInstances Defines wether will draw in the map using instances
  9866. * @returns true if ready otherwise, false
  9867. */
  9868. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9869. /**
  9870. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9871. * @param defines Defines of the material we want to update
  9872. * @param lightIndex Index of the light in the enabled light list of the material
  9873. */
  9874. prepareDefines(defines: any, lightIndex: number): void;
  9875. /**
  9876. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9877. * defined in the generator but impacting the effect).
  9878. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9879. * @param effect The effect we are binfing the information for
  9880. */
  9881. bindShadowLight(lightIndex: string, effect: Effect): void;
  9882. /**
  9883. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9884. * (eq to shadow prjection matrix * light transform matrix)
  9885. * @returns The transform matrix used to create the shadow map
  9886. */
  9887. getTransformMatrix(): Matrix;
  9888. /**
  9889. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9890. * Cube and 2D textures for instance.
  9891. */
  9892. recreateShadowMap(): void;
  9893. private _disposeBlurPostProcesses;
  9894. private _disposeRTTandPostProcesses;
  9895. /**
  9896. * Disposes the ShadowGenerator.
  9897. * Returns nothing.
  9898. */
  9899. dispose(): void;
  9900. /**
  9901. * Serializes the shadow generator setup to a json object.
  9902. * @returns The serialized JSON object
  9903. */
  9904. serialize(): any;
  9905. /**
  9906. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9907. * @param parsedShadowGenerator The JSON object to parse
  9908. * @param scene The scene to create the shadow map for
  9909. * @returns The parsed shadow generator
  9910. */
  9911. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9912. }
  9913. }
  9914. declare module BABYLON {
  9915. /**
  9916. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9917. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9918. * 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.
  9919. */
  9920. export abstract class Light extends Node {
  9921. /**
  9922. * Falloff Default: light is falling off following the material specification:
  9923. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9924. */
  9925. static readonly FALLOFF_DEFAULT: number;
  9926. /**
  9927. * Falloff Physical: light is falling off following the inverse squared distance law.
  9928. */
  9929. static readonly FALLOFF_PHYSICAL: number;
  9930. /**
  9931. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9932. * to enhance interoperability with other engines.
  9933. */
  9934. static readonly FALLOFF_GLTF: number;
  9935. /**
  9936. * Falloff Standard: light is falling off like in the standard material
  9937. * to enhance interoperability with other materials.
  9938. */
  9939. static readonly FALLOFF_STANDARD: number;
  9940. /**
  9941. * If every light affecting the material is in this lightmapMode,
  9942. * material.lightmapTexture adds or multiplies
  9943. * (depends on material.useLightmapAsShadowmap)
  9944. * after every other light calculations.
  9945. */
  9946. static readonly LIGHTMAP_DEFAULT: number;
  9947. /**
  9948. * material.lightmapTexture as only diffuse lighting from this light
  9949. * adds only specular lighting from this light
  9950. * adds dynamic shadows
  9951. */
  9952. static readonly LIGHTMAP_SPECULAR: number;
  9953. /**
  9954. * material.lightmapTexture as only lighting
  9955. * no light calculation from this light
  9956. * only adds dynamic shadows from this light
  9957. */
  9958. static readonly LIGHTMAP_SHADOWSONLY: number;
  9959. /**
  9960. * Each light type uses the default quantity according to its type:
  9961. * point/spot lights use luminous intensity
  9962. * directional lights use illuminance
  9963. */
  9964. static readonly INTENSITYMODE_AUTOMATIC: number;
  9965. /**
  9966. * lumen (lm)
  9967. */
  9968. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9969. /**
  9970. * candela (lm/sr)
  9971. */
  9972. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9973. /**
  9974. * lux (lm/m^2)
  9975. */
  9976. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9977. /**
  9978. * nit (cd/m^2)
  9979. */
  9980. static readonly INTENSITYMODE_LUMINANCE: number;
  9981. /**
  9982. * Light type const id of the point light.
  9983. */
  9984. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9985. /**
  9986. * Light type const id of the directional light.
  9987. */
  9988. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9989. /**
  9990. * Light type const id of the spot light.
  9991. */
  9992. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9993. /**
  9994. * Light type const id of the hemispheric light.
  9995. */
  9996. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9997. /**
  9998. * Diffuse gives the basic color to an object.
  9999. */
  10000. diffuse: Color3;
  10001. /**
  10002. * Specular produces a highlight color on an object.
  10003. * Note: This is note affecting PBR materials.
  10004. */
  10005. specular: Color3;
  10006. /**
  10007. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10008. * falling off base on range or angle.
  10009. * This can be set to any values in Light.FALLOFF_x.
  10010. *
  10011. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10012. * other types of materials.
  10013. */
  10014. falloffType: number;
  10015. /**
  10016. * Strength of the light.
  10017. * Note: By default it is define in the framework own unit.
  10018. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10019. */
  10020. intensity: number;
  10021. private _range;
  10022. protected _inverseSquaredRange: number;
  10023. /**
  10024. * Defines how far from the source the light is impacting in scene units.
  10025. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10026. */
  10027. /**
  10028. * Defines how far from the source the light is impacting in scene units.
  10029. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10030. */
  10031. range: number;
  10032. /**
  10033. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10034. * of light.
  10035. */
  10036. private _photometricScale;
  10037. private _intensityMode;
  10038. /**
  10039. * Gets the photometric scale used to interpret the intensity.
  10040. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10041. */
  10042. /**
  10043. * Sets the photometric scale used to interpret the intensity.
  10044. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10045. */
  10046. intensityMode: number;
  10047. private _radius;
  10048. /**
  10049. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10050. */
  10051. /**
  10052. * sets the light radius used by PBR Materials to simulate soft area lights.
  10053. */
  10054. radius: number;
  10055. private _renderPriority;
  10056. /**
  10057. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10058. * exceeding the number allowed of the materials.
  10059. */
  10060. renderPriority: number;
  10061. private _shadowEnabled;
  10062. /**
  10063. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10064. * the current shadow generator.
  10065. */
  10066. /**
  10067. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10068. * the current shadow generator.
  10069. */
  10070. shadowEnabled: boolean;
  10071. private _includedOnlyMeshes;
  10072. /**
  10073. * Gets the only meshes impacted by this light.
  10074. */
  10075. /**
  10076. * Sets the only meshes impacted by this light.
  10077. */
  10078. includedOnlyMeshes: AbstractMesh[];
  10079. private _excludedMeshes;
  10080. /**
  10081. * Gets the meshes not impacted by this light.
  10082. */
  10083. /**
  10084. * Sets the meshes not impacted by this light.
  10085. */
  10086. excludedMeshes: AbstractMesh[];
  10087. private _excludeWithLayerMask;
  10088. /**
  10089. * Gets the layer id use to find what meshes are not impacted by the light.
  10090. * Inactive if 0
  10091. */
  10092. /**
  10093. * Sets the layer id use to find what meshes are not impacted by the light.
  10094. * Inactive if 0
  10095. */
  10096. excludeWithLayerMask: number;
  10097. private _includeOnlyWithLayerMask;
  10098. /**
  10099. * Gets the layer id use to find what meshes are impacted by the light.
  10100. * Inactive if 0
  10101. */
  10102. /**
  10103. * Sets the layer id use to find what meshes are impacted by the light.
  10104. * Inactive if 0
  10105. */
  10106. includeOnlyWithLayerMask: number;
  10107. private _lightmapMode;
  10108. /**
  10109. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10110. */
  10111. /**
  10112. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10113. */
  10114. lightmapMode: number;
  10115. /**
  10116. * Shadow generator associted to the light.
  10117. * @hidden Internal use only.
  10118. */ shadowGenerator: Nullable<IShadowGenerator>;
  10119. /**
  10120. * @hidden Internal use only.
  10121. */ excludedMeshesIds: string[];
  10122. /**
  10123. * @hidden Internal use only.
  10124. */ includedOnlyMeshesIds: string[];
  10125. /**
  10126. * The current light unifom buffer.
  10127. * @hidden Internal use only.
  10128. */ uniformBuffer: UniformBuffer;
  10129. /**
  10130. * Creates a Light object in the scene.
  10131. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10132. * @param name The firendly name of the light
  10133. * @param scene The scene the light belongs too
  10134. */
  10135. constructor(name: string, scene: Scene);
  10136. protected abstract _buildUniformLayout(): void;
  10137. /**
  10138. * Sets the passed Effect "effect" with the Light information.
  10139. * @param effect The effect to update
  10140. * @param lightIndex The index of the light in the effect to update
  10141. * @returns The light
  10142. */
  10143. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10144. /**
  10145. * Returns the string "Light".
  10146. * @returns the class name
  10147. */
  10148. getClassName(): string;
  10149. /** @hidden */ protected readonly _isLight: boolean;
  10150. /**
  10151. * Converts the light information to a readable string for debug purpose.
  10152. * @param fullDetails Supports for multiple levels of logging within scene loading
  10153. * @returns the human readable light info
  10154. */
  10155. toString(fullDetails?: boolean): string;
  10156. /** @hidden */
  10157. protected _syncParentEnabledState(): void;
  10158. /**
  10159. * Set the enabled state of this node.
  10160. * @param value - the new enabled state
  10161. */
  10162. setEnabled(value: boolean): void;
  10163. /**
  10164. * Returns the Light associated shadow generator if any.
  10165. * @return the associated shadow generator.
  10166. */
  10167. getShadowGenerator(): Nullable<IShadowGenerator>;
  10168. /**
  10169. * Returns a Vector3, the absolute light position in the World.
  10170. * @returns the world space position of the light
  10171. */
  10172. getAbsolutePosition(): Vector3;
  10173. /**
  10174. * Specifies if the light will affect the passed mesh.
  10175. * @param mesh The mesh to test against the light
  10176. * @return true the mesh is affected otherwise, false.
  10177. */
  10178. canAffectMesh(mesh: AbstractMesh): boolean;
  10179. /**
  10180. * Sort function to order lights for rendering.
  10181. * @param a First Light object to compare to second.
  10182. * @param b Second Light object to compare first.
  10183. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10184. */
  10185. static CompareLightsPriority(a: Light, b: Light): number;
  10186. /**
  10187. * Releases resources associated with this node.
  10188. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10189. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10190. */
  10191. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10192. /**
  10193. * Returns the light type ID (integer).
  10194. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10195. */
  10196. getTypeID(): number;
  10197. /**
  10198. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10199. * @returns the scaled intensity in intensity mode unit
  10200. */
  10201. getScaledIntensity(): number;
  10202. /**
  10203. * Returns a new Light object, named "name", from the current one.
  10204. * @param name The name of the cloned light
  10205. * @returns the new created light
  10206. */
  10207. clone(name: string): Nullable<Light>;
  10208. /**
  10209. * Serializes the current light into a Serialization object.
  10210. * @returns the serialized object.
  10211. */
  10212. serialize(): any;
  10213. /**
  10214. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10215. * This new light is named "name" and added to the passed scene.
  10216. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10217. * @param name The friendly name of the light
  10218. * @param scene The scene the new light will belong to
  10219. * @returns the constructor function
  10220. */
  10221. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10222. /**
  10223. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10224. * @param parsedLight The JSON representation of the light
  10225. * @param scene The scene to create the parsed light in
  10226. * @returns the created light after parsing
  10227. */
  10228. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10229. private _hookArrayForExcluded;
  10230. private _hookArrayForIncludedOnly;
  10231. private _resyncMeshes;
  10232. /**
  10233. * Forces the meshes to update their light related information in their rendering used effects
  10234. * @hidden Internal Use Only
  10235. */ markMeshesAsLightDirty(): void;
  10236. /**
  10237. * Recomputes the cached photometric scale if needed.
  10238. */
  10239. private _computePhotometricScale;
  10240. /**
  10241. * Returns the Photometric Scale according to the light type and intensity mode.
  10242. */
  10243. private _getPhotometricScale;
  10244. /**
  10245. * Reorder the light in the scene according to their defined priority.
  10246. * @hidden Internal Use Only
  10247. */ reorderLightsInScene(): void;
  10248. /**
  10249. * Prepares the list of defines specific to the light type.
  10250. * @param defines the list of defines
  10251. * @param lightIndex defines the index of the light for the effect
  10252. */
  10253. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10254. }
  10255. }
  10256. declare module BABYLON {
  10257. /**
  10258. * Interface used to define Action
  10259. */
  10260. export interface IAction {
  10261. /**
  10262. * Trigger for the action
  10263. */
  10264. trigger: number;
  10265. /** Options of the trigger */
  10266. triggerOptions: any;
  10267. /**
  10268. * Gets the trigger parameters
  10269. * @returns the trigger parameters
  10270. */
  10271. getTriggerParameter(): any;
  10272. /**
  10273. * Internal only - executes current action event
  10274. * @hidden
  10275. */ executeCurrent(evt?: ActionEvent): void;
  10276. /**
  10277. * Serialize placeholder for child classes
  10278. * @param parent of child
  10279. * @returns the serialized object
  10280. */
  10281. serialize(parent: any): any;
  10282. /**
  10283. * Internal only
  10284. * @hidden
  10285. */ prepare(): void;
  10286. /**
  10287. * Internal only - manager for action
  10288. * @hidden
  10289. */ actionManager: AbstractActionManager;
  10290. }
  10291. /**
  10292. * The action to be carried out following a trigger
  10293. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10294. */
  10295. export class Action implements IAction {
  10296. /** the trigger, with or without parameters, for the action */
  10297. triggerOptions: any;
  10298. /**
  10299. * Trigger for the action
  10300. */
  10301. trigger: number;
  10302. /**
  10303. * Internal only - manager for action
  10304. * @hidden
  10305. */ actionManager: ActionManager;
  10306. private _nextActiveAction;
  10307. private _child;
  10308. private _condition?;
  10309. private _triggerParameter;
  10310. /**
  10311. * An event triggered prior to action being executed.
  10312. */
  10313. onBeforeExecuteObservable: Observable<Action>;
  10314. /**
  10315. * Creates a new Action
  10316. * @param triggerOptions the trigger, with or without parameters, for the action
  10317. * @param condition an optional determinant of action
  10318. */
  10319. constructor(
  10320. /** the trigger, with or without parameters, for the action */
  10321. triggerOptions: any, condition?: Condition);
  10322. /**
  10323. * Internal only
  10324. * @hidden
  10325. */ prepare(): void;
  10326. /**
  10327. * Gets the trigger parameters
  10328. * @returns the trigger parameters
  10329. */
  10330. getTriggerParameter(): any;
  10331. /**
  10332. * Internal only - executes current action event
  10333. * @hidden
  10334. */ executeCurrent(evt?: ActionEvent): void;
  10335. /**
  10336. * Execute placeholder for child classes
  10337. * @param evt optional action event
  10338. */
  10339. execute(evt?: ActionEvent): void;
  10340. /**
  10341. * Skips to next active action
  10342. */
  10343. skipToNextActiveAction(): void;
  10344. /**
  10345. * Adds action to chain of actions, may be a DoNothingAction
  10346. * @param action defines the next action to execute
  10347. * @returns The action passed in
  10348. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10349. */
  10350. then(action: Action): Action;
  10351. /**
  10352. * Internal only
  10353. * @hidden
  10354. */ getProperty(propertyPath: string): string;
  10355. /**
  10356. * Internal only
  10357. * @hidden
  10358. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10359. /**
  10360. * Serialize placeholder for child classes
  10361. * @param parent of child
  10362. * @returns the serialized object
  10363. */
  10364. serialize(parent: any): any;
  10365. /**
  10366. * Internal only called by serialize
  10367. * @hidden
  10368. */
  10369. protected _serialize(serializedAction: any, parent?: any): any;
  10370. /**
  10371. * Internal only
  10372. * @hidden
  10373. */ private static _SerializeValueAsString: (value: any) => string;
  10374. /**
  10375. * Internal only
  10376. * @hidden
  10377. */ private static _GetTargetProperty: (target: Scene | Node) => {
  10378. name: string;
  10379. targetType: string;
  10380. value: string;
  10381. };
  10382. }
  10383. }
  10384. declare module BABYLON {
  10385. /**
  10386. * A Condition applied to an Action
  10387. */
  10388. export class Condition {
  10389. /**
  10390. * Internal only - manager for action
  10391. * @hidden
  10392. */ actionManager: ActionManager;
  10393. /**
  10394. * Internal only
  10395. * @hidden
  10396. */ evaluationId: number;
  10397. /**
  10398. * Internal only
  10399. * @hidden
  10400. */ currentResult: boolean;
  10401. /**
  10402. * Creates a new Condition
  10403. * @param actionManager the manager of the action the condition is applied to
  10404. */
  10405. constructor(actionManager: ActionManager);
  10406. /**
  10407. * Check if the current condition is valid
  10408. * @returns a boolean
  10409. */
  10410. isValid(): boolean;
  10411. /**
  10412. * Internal only
  10413. * @hidden
  10414. */ getProperty(propertyPath: string): string;
  10415. /**
  10416. * Internal only
  10417. * @hidden
  10418. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10419. /**
  10420. * Serialize placeholder for child classes
  10421. * @returns the serialized object
  10422. */
  10423. serialize(): any;
  10424. /**
  10425. * Internal only
  10426. * @hidden
  10427. */
  10428. protected _serialize(serializedCondition: any): any;
  10429. }
  10430. /**
  10431. * Defines specific conditional operators as extensions of Condition
  10432. */
  10433. export class ValueCondition extends Condition {
  10434. /** path to specify the property of the target the conditional operator uses */
  10435. propertyPath: string;
  10436. /** the value compared by the conditional operator against the current value of the property */
  10437. value: any;
  10438. /** the conditional operator, default ValueCondition.IsEqual */
  10439. operator: number;
  10440. /**
  10441. * Internal only
  10442. * @hidden
  10443. */
  10444. private static _IsEqual;
  10445. /**
  10446. * Internal only
  10447. * @hidden
  10448. */
  10449. private static _IsDifferent;
  10450. /**
  10451. * Internal only
  10452. * @hidden
  10453. */
  10454. private static _IsGreater;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. private static _IsLesser;
  10460. /**
  10461. * returns the number for IsEqual
  10462. */
  10463. static readonly IsEqual: number;
  10464. /**
  10465. * Returns the number for IsDifferent
  10466. */
  10467. static readonly IsDifferent: number;
  10468. /**
  10469. * Returns the number for IsGreater
  10470. */
  10471. static readonly IsGreater: number;
  10472. /**
  10473. * Returns the number for IsLesser
  10474. */
  10475. static readonly IsLesser: number;
  10476. /**
  10477. * Internal only The action manager for the condition
  10478. * @hidden
  10479. */ actionManager: ActionManager;
  10480. /**
  10481. * Internal only
  10482. * @hidden
  10483. */
  10484. private _target;
  10485. /**
  10486. * Internal only
  10487. * @hidden
  10488. */
  10489. private _effectiveTarget;
  10490. /**
  10491. * Internal only
  10492. * @hidden
  10493. */
  10494. private _property;
  10495. /**
  10496. * Creates a new ValueCondition
  10497. * @param actionManager manager for the action the condition applies to
  10498. * @param target for the action
  10499. * @param propertyPath path to specify the property of the target the conditional operator uses
  10500. * @param value the value compared by the conditional operator against the current value of the property
  10501. * @param operator the conditional operator, default ValueCondition.IsEqual
  10502. */
  10503. constructor(actionManager: ActionManager, target: any,
  10504. /** path to specify the property of the target the conditional operator uses */
  10505. propertyPath: string,
  10506. /** the value compared by the conditional operator against the current value of the property */
  10507. value: any,
  10508. /** the conditional operator, default ValueCondition.IsEqual */
  10509. operator?: number);
  10510. /**
  10511. * Compares the given value with the property value for the specified conditional operator
  10512. * @returns the result of the comparison
  10513. */
  10514. isValid(): boolean;
  10515. /**
  10516. * Serialize the ValueCondition into a JSON compatible object
  10517. * @returns serialization object
  10518. */
  10519. serialize(): any;
  10520. /**
  10521. * Gets the name of the conditional operator for the ValueCondition
  10522. * @param operator the conditional operator
  10523. * @returns the name
  10524. */
  10525. static GetOperatorName(operator: number): string;
  10526. }
  10527. /**
  10528. * Defines a predicate condition as an extension of Condition
  10529. */
  10530. export class PredicateCondition extends Condition {
  10531. /** defines the predicate function used to validate the condition */
  10532. predicate: () => boolean;
  10533. /**
  10534. * Internal only - manager for action
  10535. * @hidden
  10536. */ actionManager: ActionManager;
  10537. /**
  10538. * Creates a new PredicateCondition
  10539. * @param actionManager manager for the action the condition applies to
  10540. * @param predicate defines the predicate function used to validate the condition
  10541. */
  10542. constructor(actionManager: ActionManager,
  10543. /** defines the predicate function used to validate the condition */
  10544. predicate: () => boolean);
  10545. /**
  10546. * @returns the validity of the predicate condition
  10547. */
  10548. isValid(): boolean;
  10549. }
  10550. /**
  10551. * Defines a state condition as an extension of Condition
  10552. */
  10553. export class StateCondition extends Condition {
  10554. /** Value to compare with target state */
  10555. value: string;
  10556. /**
  10557. * Internal only - manager for action
  10558. * @hidden
  10559. */ actionManager: ActionManager;
  10560. /**
  10561. * Internal only
  10562. * @hidden
  10563. */
  10564. private _target;
  10565. /**
  10566. * Creates a new StateCondition
  10567. * @param actionManager manager for the action the condition applies to
  10568. * @param target of the condition
  10569. * @param value to compare with target state
  10570. */
  10571. constructor(actionManager: ActionManager, target: any,
  10572. /** Value to compare with target state */
  10573. value: string);
  10574. /**
  10575. * Gets a boolean indicating if the current condition is met
  10576. * @returns the validity of the state
  10577. */
  10578. isValid(): boolean;
  10579. /**
  10580. * Serialize the StateCondition into a JSON compatible object
  10581. * @returns serialization object
  10582. */
  10583. serialize(): any;
  10584. }
  10585. }
  10586. declare module BABYLON {
  10587. /**
  10588. * This defines an action responsible to toggle a boolean once triggered.
  10589. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10590. */
  10591. export class SwitchBooleanAction extends Action {
  10592. /**
  10593. * The path to the boolean property in the target object
  10594. */
  10595. propertyPath: string;
  10596. private _target;
  10597. private _effectiveTarget;
  10598. private _property;
  10599. /**
  10600. * Instantiate the action
  10601. * @param triggerOptions defines the trigger options
  10602. * @param target defines the object containing the boolean
  10603. * @param propertyPath defines the path to the boolean property in the target object
  10604. * @param condition defines the trigger related conditions
  10605. */
  10606. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10607. /** @hidden */ prepare(): void;
  10608. /**
  10609. * Execute the action toggle the boolean value.
  10610. */
  10611. execute(): void;
  10612. /**
  10613. * Serializes the actions and its related information.
  10614. * @param parent defines the object to serialize in
  10615. * @returns the serialized object
  10616. */
  10617. serialize(parent: any): any;
  10618. }
  10619. /**
  10620. * This defines an action responsible to set a the state field of the target
  10621. * to a desired value once triggered.
  10622. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10623. */
  10624. export class SetStateAction extends Action {
  10625. /**
  10626. * The value to store in the state field.
  10627. */
  10628. value: string;
  10629. private _target;
  10630. /**
  10631. * Instantiate the action
  10632. * @param triggerOptions defines the trigger options
  10633. * @param target defines the object containing the state property
  10634. * @param value defines the value to store in the state field
  10635. * @param condition defines the trigger related conditions
  10636. */
  10637. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10638. /**
  10639. * Execute the action and store the value on the target state property.
  10640. */
  10641. execute(): void;
  10642. /**
  10643. * Serializes the actions and its related information.
  10644. * @param parent defines the object to serialize in
  10645. * @returns the serialized object
  10646. */
  10647. serialize(parent: any): any;
  10648. }
  10649. /**
  10650. * This defines an action responsible to set a property of the target
  10651. * to a desired value once triggered.
  10652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10653. */
  10654. export class SetValueAction extends Action {
  10655. /**
  10656. * The path of the property to set in the target.
  10657. */
  10658. propertyPath: string;
  10659. /**
  10660. * The value to set in the property
  10661. */
  10662. value: any;
  10663. private _target;
  10664. private _effectiveTarget;
  10665. private _property;
  10666. /**
  10667. * Instantiate the action
  10668. * @param triggerOptions defines the trigger options
  10669. * @param target defines the object containing the property
  10670. * @param propertyPath defines the path of the property to set in the target
  10671. * @param value defines the value to set in the property
  10672. * @param condition defines the trigger related conditions
  10673. */
  10674. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10675. /** @hidden */ prepare(): void;
  10676. /**
  10677. * Execute the action and set the targetted property to the desired value.
  10678. */
  10679. execute(): void;
  10680. /**
  10681. * Serializes the actions and its related information.
  10682. * @param parent defines the object to serialize in
  10683. * @returns the serialized object
  10684. */
  10685. serialize(parent: any): any;
  10686. }
  10687. /**
  10688. * This defines an action responsible to increment the target value
  10689. * to a desired value once triggered.
  10690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10691. */
  10692. export class IncrementValueAction extends Action {
  10693. /**
  10694. * The path of the property to increment in the target.
  10695. */
  10696. propertyPath: string;
  10697. /**
  10698. * The value we should increment the property by.
  10699. */
  10700. value: any;
  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 property
  10708. * @param propertyPath defines the path of the property to increment in the target
  10709. * @param value defines the value value we should increment the property by
  10710. * @param condition defines the trigger related conditions
  10711. */
  10712. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10713. /** @hidden */ prepare(): void;
  10714. /**
  10715. * Execute the action and increment the target of the value amount.
  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 start an animation once triggered.
  10727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10728. */
  10729. export class PlayAnimationAction extends Action {
  10730. /**
  10731. * Where the animation should start (animation frame)
  10732. */
  10733. from: number;
  10734. /**
  10735. * Where the animation should stop (animation frame)
  10736. */
  10737. to: number;
  10738. /**
  10739. * Define if the animation should loop or stop after the first play.
  10740. */
  10741. loop?: boolean;
  10742. private _target;
  10743. /**
  10744. * Instantiate the action
  10745. * @param triggerOptions defines the trigger options
  10746. * @param target defines the target animation or animation name
  10747. * @param from defines from where the animation should start (animation frame)
  10748. * @param end defines where the animation should stop (animation frame)
  10749. * @param loop defines if the animation should loop or stop after the first play
  10750. * @param condition defines the trigger related conditions
  10751. */
  10752. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10753. /** @hidden */ prepare(): void;
  10754. /**
  10755. * Execute the action and play the animation.
  10756. */
  10757. execute(): void;
  10758. /**
  10759. * Serializes the actions and its related information.
  10760. * @param parent defines the object to serialize in
  10761. * @returns the serialized object
  10762. */
  10763. serialize(parent: any): any;
  10764. }
  10765. /**
  10766. * This defines an action responsible to stop an animation once triggered.
  10767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10768. */
  10769. export class StopAnimationAction extends Action {
  10770. private _target;
  10771. /**
  10772. * Instantiate the action
  10773. * @param triggerOptions defines the trigger options
  10774. * @param target defines the target animation or animation name
  10775. * @param condition defines the trigger related conditions
  10776. */
  10777. constructor(triggerOptions: any, target: any, condition?: Condition);
  10778. /** @hidden */ prepare(): void;
  10779. /**
  10780. * Execute the action and stop the animation.
  10781. */
  10782. execute(): void;
  10783. /**
  10784. * Serializes the actions and its related information.
  10785. * @param parent defines the object to serialize in
  10786. * @returns the serialized object
  10787. */
  10788. serialize(parent: any): any;
  10789. }
  10790. /**
  10791. * This defines an action responsible that does nothing once triggered.
  10792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10793. */
  10794. export class DoNothingAction extends Action {
  10795. /**
  10796. * Instantiate the action
  10797. * @param triggerOptions defines the trigger options
  10798. * @param condition defines the trigger related conditions
  10799. */
  10800. constructor(triggerOptions?: any, condition?: Condition);
  10801. /**
  10802. * Execute the action and do nothing.
  10803. */
  10804. execute(): void;
  10805. /**
  10806. * Serializes the actions and its related information.
  10807. * @param parent defines the object to serialize in
  10808. * @returns the serialized object
  10809. */
  10810. serialize(parent: any): any;
  10811. }
  10812. /**
  10813. * This defines an action responsible to trigger several actions once triggered.
  10814. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10815. */
  10816. export class CombineAction extends Action {
  10817. /**
  10818. * The list of aggregated animations to run.
  10819. */
  10820. children: Action[];
  10821. /**
  10822. * Instantiate the action
  10823. * @param triggerOptions defines the trigger options
  10824. * @param children defines the list of aggregated animations to run
  10825. * @param condition defines the trigger related conditions
  10826. */
  10827. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10828. /** @hidden */ prepare(): void;
  10829. /**
  10830. * Execute the action and executes all the aggregated actions.
  10831. */
  10832. execute(evt: ActionEvent): void;
  10833. /**
  10834. * Serializes the actions and its related information.
  10835. * @param parent defines the object to serialize in
  10836. * @returns the serialized object
  10837. */
  10838. serialize(parent: any): any;
  10839. }
  10840. /**
  10841. * This defines an action responsible to run code (external event) once triggered.
  10842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10843. */
  10844. export class ExecuteCodeAction extends Action {
  10845. /**
  10846. * The callback function to run.
  10847. */
  10848. func: (evt: ActionEvent) => void;
  10849. /**
  10850. * Instantiate the action
  10851. * @param triggerOptions defines the trigger options
  10852. * @param func defines the callback function to run
  10853. * @param condition defines the trigger related conditions
  10854. */
  10855. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10856. /**
  10857. * Execute the action and run the attached code.
  10858. */
  10859. execute(evt: ActionEvent): void;
  10860. }
  10861. /**
  10862. * This defines an action responsible to set the parent property of the target once triggered.
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10864. */
  10865. export class SetParentAction extends Action {
  10866. private _parent;
  10867. private _target;
  10868. /**
  10869. * Instantiate the action
  10870. * @param triggerOptions defines the trigger options
  10871. * @param target defines the target containing the parent property
  10872. * @param parent defines from where the animation should start (animation frame)
  10873. * @param condition defines the trigger related conditions
  10874. */
  10875. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10876. /** @hidden */ prepare(): void;
  10877. /**
  10878. * Execute the action and set the parent property.
  10879. */
  10880. execute(): void;
  10881. /**
  10882. * Serializes the actions and its related information.
  10883. * @param parent defines the object to serialize in
  10884. * @returns the serialized object
  10885. */
  10886. serialize(parent: any): any;
  10887. }
  10888. }
  10889. declare module BABYLON {
  10890. /**
  10891. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10892. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10894. */
  10895. export class ActionManager extends AbstractActionManager {
  10896. /**
  10897. * Nothing
  10898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10899. */
  10900. static readonly NothingTrigger: number;
  10901. /**
  10902. * On pick
  10903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10904. */
  10905. static readonly OnPickTrigger: number;
  10906. /**
  10907. * On left pick
  10908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10909. */
  10910. static readonly OnLeftPickTrigger: number;
  10911. /**
  10912. * On right pick
  10913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10914. */
  10915. static readonly OnRightPickTrigger: number;
  10916. /**
  10917. * On center pick
  10918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10919. */
  10920. static readonly OnCenterPickTrigger: number;
  10921. /**
  10922. * On pick down
  10923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10924. */
  10925. static readonly OnPickDownTrigger: number;
  10926. /**
  10927. * On double pick
  10928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10929. */
  10930. static readonly OnDoublePickTrigger: number;
  10931. /**
  10932. * On pick up
  10933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10934. */
  10935. static readonly OnPickUpTrigger: number;
  10936. /**
  10937. * On pick out.
  10938. * This trigger will only be raised if you also declared a OnPickDown
  10939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10940. */
  10941. static readonly OnPickOutTrigger: number;
  10942. /**
  10943. * On long press
  10944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10945. */
  10946. static readonly OnLongPressTrigger: number;
  10947. /**
  10948. * On pointer over
  10949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10950. */
  10951. static readonly OnPointerOverTrigger: number;
  10952. /**
  10953. * On pointer out
  10954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10955. */
  10956. static readonly OnPointerOutTrigger: number;
  10957. /**
  10958. * On every frame
  10959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10960. */
  10961. static readonly OnEveryFrameTrigger: number;
  10962. /**
  10963. * On intersection enter
  10964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10965. */
  10966. static readonly OnIntersectionEnterTrigger: number;
  10967. /**
  10968. * On intersection exit
  10969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10970. */
  10971. static readonly OnIntersectionExitTrigger: number;
  10972. /**
  10973. * On key down
  10974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10975. */
  10976. static readonly OnKeyDownTrigger: number;
  10977. /**
  10978. * On key up
  10979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10980. */
  10981. static readonly OnKeyUpTrigger: number;
  10982. private _scene;
  10983. /**
  10984. * Creates a new action manager
  10985. * @param scene defines the hosting scene
  10986. */
  10987. constructor(scene: Scene);
  10988. /**
  10989. * Releases all associated resources
  10990. */
  10991. dispose(): void;
  10992. /**
  10993. * Gets hosting scene
  10994. * @returns the hosting scene
  10995. */
  10996. getScene(): Scene;
  10997. /**
  10998. * Does this action manager handles actions of any of the given triggers
  10999. * @param triggers defines the triggers to be tested
  11000. * @return a boolean indicating whether one (or more) of the triggers is handled
  11001. */
  11002. hasSpecificTriggers(triggers: number[]): boolean;
  11003. /**
  11004. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11005. * speed.
  11006. * @param triggerA defines the trigger to be tested
  11007. * @param triggerB defines the trigger to be tested
  11008. * @return a boolean indicating whether one (or more) of the triggers is handled
  11009. */
  11010. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11011. /**
  11012. * Does this action manager handles actions of a given trigger
  11013. * @param trigger defines the trigger to be tested
  11014. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11015. * @return whether the trigger is handled
  11016. */
  11017. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11018. /**
  11019. * Does this action manager has pointer triggers
  11020. */
  11021. readonly hasPointerTriggers: boolean;
  11022. /**
  11023. * Does this action manager has pick triggers
  11024. */
  11025. readonly hasPickTriggers: boolean;
  11026. /**
  11027. * Registers an action to this action manager
  11028. * @param action defines the action to be registered
  11029. * @return the action amended (prepared) after registration
  11030. */
  11031. registerAction(action: IAction): Nullable<IAction>;
  11032. /**
  11033. * Unregisters an action to this action manager
  11034. * @param action defines the action to be unregistered
  11035. * @return a boolean indicating whether the action has been unregistered
  11036. */
  11037. unregisterAction(action: IAction): Boolean;
  11038. /**
  11039. * Process a specific trigger
  11040. * @param trigger defines the trigger to process
  11041. * @param evt defines the event details to be processed
  11042. */
  11043. processTrigger(trigger: number, evt?: IActionEvent): void;
  11044. /** @hidden */ getEffectiveTarget(target: any, propertyPath: string): any;
  11045. /** @hidden */ getProperty(propertyPath: string): string;
  11046. /**
  11047. * Serialize this manager to a JSON object
  11048. * @param name defines the property name to store this manager
  11049. * @returns a JSON representation of this manager
  11050. */
  11051. serialize(name: string): any;
  11052. /**
  11053. * Creates a new ActionManager from a JSON data
  11054. * @param parsedActions defines the JSON data to read from
  11055. * @param object defines the hosting mesh
  11056. * @param scene defines the hosting scene
  11057. */
  11058. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11059. /**
  11060. * Get a trigger name by index
  11061. * @param trigger defines the trigger index
  11062. * @returns a trigger name
  11063. */
  11064. static GetTriggerName(trigger: number): string;
  11065. }
  11066. }
  11067. declare module BABYLON {
  11068. /**
  11069. * Class representing a ray with position and direction
  11070. */
  11071. export class Ray {
  11072. /** origin point */
  11073. origin: Vector3;
  11074. /** direction */
  11075. direction: Vector3;
  11076. /** length of the ray */
  11077. length: number;
  11078. private static readonly TmpVector3;
  11079. private _tmpRay;
  11080. /**
  11081. * Creates a new ray
  11082. * @param origin origin point
  11083. * @param direction direction
  11084. * @param length length of the ray
  11085. */
  11086. constructor(
  11087. /** origin point */
  11088. origin: Vector3,
  11089. /** direction */
  11090. direction: Vector3,
  11091. /** length of the ray */
  11092. length?: number);
  11093. /**
  11094. * Checks if the ray intersects a box
  11095. * @param minimum bound of the box
  11096. * @param maximum bound of the box
  11097. * @param intersectionTreshold extra extend to be added to the box in all direction
  11098. * @returns if the box was hit
  11099. */
  11100. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11101. /**
  11102. * Checks if the ray intersects a box
  11103. * @param box the bounding box to check
  11104. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11105. * @returns if the box was hit
  11106. */
  11107. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11108. /**
  11109. * If the ray hits a sphere
  11110. * @param sphere the bounding sphere to check
  11111. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11112. * @returns true if it hits the sphere
  11113. */
  11114. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11115. /**
  11116. * If the ray hits a triange
  11117. * @param vertex0 triangle vertex
  11118. * @param vertex1 triangle vertex
  11119. * @param vertex2 triangle vertex
  11120. * @returns intersection information if hit
  11121. */
  11122. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11123. /**
  11124. * Checks if ray intersects a plane
  11125. * @param plane the plane to check
  11126. * @returns the distance away it was hit
  11127. */
  11128. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11129. /**
  11130. * Checks if ray intersects a mesh
  11131. * @param mesh the mesh to check
  11132. * @param fastCheck if only the bounding box should checked
  11133. * @returns picking info of the intersecton
  11134. */
  11135. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11136. /**
  11137. * Checks if ray intersects a mesh
  11138. * @param meshes the meshes to check
  11139. * @param fastCheck if only the bounding box should checked
  11140. * @param results array to store result in
  11141. * @returns Array of picking infos
  11142. */
  11143. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11144. private _comparePickingInfo;
  11145. private static smallnum;
  11146. private static rayl;
  11147. /**
  11148. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11149. * @param sega the first point of the segment to test the intersection against
  11150. * @param segb the second point of the segment to test the intersection against
  11151. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11152. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11153. */
  11154. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11155. /**
  11156. * Update the ray from viewport position
  11157. * @param x position
  11158. * @param y y position
  11159. * @param viewportWidth viewport width
  11160. * @param viewportHeight viewport height
  11161. * @param world world matrix
  11162. * @param view view matrix
  11163. * @param projection projection matrix
  11164. * @returns this ray updated
  11165. */
  11166. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11167. /**
  11168. * Creates a ray with origin and direction of 0,0,0
  11169. * @returns the new ray
  11170. */
  11171. static Zero(): Ray;
  11172. /**
  11173. * Creates a new ray from screen space and viewport
  11174. * @param x position
  11175. * @param y y position
  11176. * @param viewportWidth viewport width
  11177. * @param viewportHeight viewport height
  11178. * @param world world matrix
  11179. * @param view view matrix
  11180. * @param projection projection matrix
  11181. * @returns new ray
  11182. */
  11183. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11184. /**
  11185. * 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
  11186. * transformed to the given world matrix.
  11187. * @param origin The origin point
  11188. * @param end The end point
  11189. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11190. * @returns the new ray
  11191. */
  11192. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11193. /**
  11194. * Transforms a ray by a matrix
  11195. * @param ray ray to transform
  11196. * @param matrix matrix to apply
  11197. * @returns the resulting new ray
  11198. */
  11199. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11200. /**
  11201. * Transforms a ray by a matrix
  11202. * @param ray ray to transform
  11203. * @param matrix matrix to apply
  11204. * @param result ray to store result in
  11205. */
  11206. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11207. /**
  11208. * Unproject a ray from screen space to object space
  11209. * @param sourceX defines the screen space x coordinate to use
  11210. * @param sourceY defines the screen space y coordinate to use
  11211. * @param viewportWidth defines the current width of the viewport
  11212. * @param viewportHeight defines the current height of the viewport
  11213. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11214. * @param view defines the view matrix to use
  11215. * @param projection defines the projection matrix to use
  11216. */
  11217. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11218. }
  11219. /**
  11220. * Type used to define predicate used to select faces when a mesh intersection is detected
  11221. */
  11222. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11223. interface Scene {
  11224. /** @hidden */ tempPickingRay: Nullable<Ray>;
  11225. /** @hidden */ cachedRayForTransform: Ray;
  11226. /** @hidden */ pickWithRayInverseMatrix: Matrix;
  11227. /** @hidden */ internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11228. /** @hidden */ internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11229. }
  11230. }
  11231. declare module BABYLON {
  11232. /**
  11233. * Groups all the scene component constants in one place to ease maintenance.
  11234. * @hidden
  11235. */
  11236. export class SceneComponentConstants {
  11237. static readonly NAME_EFFECTLAYER: string;
  11238. static readonly NAME_LAYER: string;
  11239. static readonly NAME_LENSFLARESYSTEM: string;
  11240. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11241. static readonly NAME_PARTICLESYSTEM: string;
  11242. static readonly NAME_GAMEPAD: string;
  11243. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11244. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11245. static readonly NAME_DEPTHRENDERER: string;
  11246. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11247. static readonly NAME_SPRITE: string;
  11248. static readonly NAME_OUTLINERENDERER: string;
  11249. static readonly NAME_PROCEDURALTEXTURE: string;
  11250. static readonly NAME_SHADOWGENERATOR: string;
  11251. static readonly NAME_OCTREE: string;
  11252. static readonly NAME_PHYSICSENGINE: string;
  11253. static readonly NAME_AUDIO: string;
  11254. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11255. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11256. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11257. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11258. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11259. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11260. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11261. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11262. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11263. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11264. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11265. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11266. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11267. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11268. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11269. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11270. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11271. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11272. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11273. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11274. static readonly STEP_AFTERRENDER_AUDIO: number;
  11275. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11276. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11277. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11278. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11279. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11280. static readonly STEP_POINTERMOVE_SPRITE: number;
  11281. static readonly STEP_POINTERDOWN_SPRITE: number;
  11282. static readonly STEP_POINTERUP_SPRITE: number;
  11283. }
  11284. /**
  11285. * This represents a scene component.
  11286. *
  11287. * This is used to decouple the dependency the scene is having on the different workloads like
  11288. * layers, post processes...
  11289. */
  11290. export interface ISceneComponent {
  11291. /**
  11292. * The name of the component. Each component must have a unique name.
  11293. */
  11294. name: string;
  11295. /**
  11296. * The scene the component belongs to.
  11297. */
  11298. scene: Scene;
  11299. /**
  11300. * Register the component to one instance of a scene.
  11301. */
  11302. register(): void;
  11303. /**
  11304. * Rebuilds the elements related to this component in case of
  11305. * context lost for instance.
  11306. */
  11307. rebuild(): void;
  11308. /**
  11309. * Disposes the component and the associated ressources.
  11310. */
  11311. dispose(): void;
  11312. }
  11313. /**
  11314. * This represents a SERIALIZABLE scene component.
  11315. *
  11316. * This extends Scene Component to add Serialization methods on top.
  11317. */
  11318. export interface ISceneSerializableComponent extends ISceneComponent {
  11319. /**
  11320. * Adds all the element from the container to the scene
  11321. * @param container the container holding the elements
  11322. */
  11323. addFromContainer(container: AbstractScene): void;
  11324. /**
  11325. * Removes all the elements in the container from the scene
  11326. * @param container contains the elements to remove
  11327. * @param dispose if the removed element should be disposed (default: false)
  11328. */
  11329. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11330. /**
  11331. * Serializes the component data to the specified json object
  11332. * @param serializationObject The object to serialize to
  11333. */
  11334. serialize(serializationObject: any): void;
  11335. }
  11336. /**
  11337. * Strong typing of a Mesh related stage step action
  11338. */
  11339. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11340. /**
  11341. * Strong typing of a Evaluate Sub Mesh related stage step action
  11342. */
  11343. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11344. /**
  11345. * Strong typing of a Active Mesh related stage step action
  11346. */
  11347. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11348. /**
  11349. * Strong typing of a Camera related stage step action
  11350. */
  11351. export type CameraStageAction = (camera: Camera) => void;
  11352. /**
  11353. * Strong typing of a Render Target related stage step action
  11354. */
  11355. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11356. /**
  11357. * Strong typing of a RenderingGroup related stage step action
  11358. */
  11359. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11360. /**
  11361. * Strong typing of a Mesh Render related stage step action
  11362. */
  11363. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11364. /**
  11365. * Strong typing of a simple stage step action
  11366. */
  11367. export type SimpleStageAction = () => void;
  11368. /**
  11369. * Strong typing of a render target action.
  11370. */
  11371. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11372. /**
  11373. * Strong typing of a pointer move action.
  11374. */
  11375. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11376. /**
  11377. * Strong typing of a pointer up/down action.
  11378. */
  11379. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11380. /**
  11381. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11382. * @hidden
  11383. */
  11384. export class Stage<T extends Function> extends Array<{
  11385. index: number;
  11386. component: ISceneComponent;
  11387. action: T;
  11388. }> {
  11389. /**
  11390. * Hide ctor from the rest of the world.
  11391. * @param items The items to add.
  11392. */
  11393. private constructor();
  11394. /**
  11395. * Creates a new Stage.
  11396. * @returns A new instance of a Stage
  11397. */
  11398. static Create<T extends Function>(): Stage<T>;
  11399. /**
  11400. * Registers a step in an ordered way in the targeted stage.
  11401. * @param index Defines the position to register the step in
  11402. * @param component Defines the component attached to the step
  11403. * @param action Defines the action to launch during the step
  11404. */
  11405. registerStep(index: number, component: ISceneComponent, action: T): void;
  11406. /**
  11407. * Clears all the steps from the stage.
  11408. */
  11409. clear(): void;
  11410. }
  11411. }
  11412. declare module BABYLON {
  11413. interface Scene {
  11414. /** @hidden */ pointerOverSprite: Nullable<Sprite>;
  11415. /** @hidden */ pickedDownSprite: Nullable<Sprite>;
  11416. /** @hidden */ tempSpritePickingRay: Nullable<Ray>;
  11417. /**
  11418. * All of the sprite managers added to this scene
  11419. * @see http://doc.babylonjs.com/babylon101/sprites
  11420. */
  11421. spriteManagers: Array<ISpriteManager>;
  11422. /**
  11423. * An event triggered when sprites rendering is about to start
  11424. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11425. */
  11426. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11427. /**
  11428. * An event triggered when sprites rendering is done
  11429. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11430. */
  11431. onAfterSpritesRenderingObservable: Observable<Scene>;
  11432. /** @hidden */ internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11433. /** Launch a ray to try to pick a sprite in the scene
  11434. * @param x position on screen
  11435. * @param y position on screen
  11436. * @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
  11437. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11438. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11439. * @returns a PickingInfo
  11440. */
  11441. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11442. /** Use the given ray to pick a sprite in the scene
  11443. * @param ray The ray (in world space) to use to pick meshes
  11444. * @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
  11445. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11446. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11447. * @returns a PickingInfo
  11448. */
  11449. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11450. /**
  11451. * Force the sprite under the pointer
  11452. * @param sprite defines the sprite to use
  11453. */
  11454. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11455. /**
  11456. * Gets the sprite under the pointer
  11457. * @returns a Sprite or null if no sprite is under the pointer
  11458. */
  11459. getPointerOverSprite(): Nullable<Sprite>;
  11460. }
  11461. /**
  11462. * Defines the sprite scene component responsible to manage sprites
  11463. * in a given scene.
  11464. */
  11465. export class SpriteSceneComponent implements ISceneComponent {
  11466. /**
  11467. * The component name helpfull to identify the component in the list of scene components.
  11468. */
  11469. readonly name: string;
  11470. /**
  11471. * The scene the component belongs to.
  11472. */
  11473. scene: Scene;
  11474. /** @hidden */
  11475. private _spritePredicate;
  11476. /**
  11477. * Creates a new instance of the component for the given scene
  11478. * @param scene Defines the scene to register the component in
  11479. */
  11480. constructor(scene: Scene);
  11481. /**
  11482. * Registers the component in a given scene
  11483. */
  11484. register(): void;
  11485. /**
  11486. * Rebuilds the elements related to this component in case of
  11487. * context lost for instance.
  11488. */
  11489. rebuild(): void;
  11490. /**
  11491. * Disposes the component and the associated ressources.
  11492. */
  11493. dispose(): void;
  11494. private _pickSpriteButKeepRay;
  11495. private _pointerMove;
  11496. private _pointerDown;
  11497. private _pointerUp;
  11498. }
  11499. }
  11500. declare module BABYLON {
  11501. /** @hidden */
  11502. export var fogFragmentDeclaration: {
  11503. name: string;
  11504. shader: string;
  11505. };
  11506. }
  11507. declare module BABYLON {
  11508. /** @hidden */
  11509. export var fogFragment: {
  11510. name: string;
  11511. shader: string;
  11512. };
  11513. }
  11514. declare module BABYLON {
  11515. /** @hidden */
  11516. export var spritesPixelShader: {
  11517. name: string;
  11518. shader: string;
  11519. };
  11520. }
  11521. declare module BABYLON {
  11522. /** @hidden */
  11523. export var fogVertexDeclaration: {
  11524. name: string;
  11525. shader: string;
  11526. };
  11527. }
  11528. declare module BABYLON {
  11529. /** @hidden */
  11530. export var spritesVertexShader: {
  11531. name: string;
  11532. shader: string;
  11533. };
  11534. }
  11535. declare module BABYLON {
  11536. /**
  11537. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11538. */
  11539. export interface ISpriteManager extends IDisposable {
  11540. /**
  11541. * Restricts the camera to viewing objects with the same layerMask.
  11542. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11543. */
  11544. layerMask: number;
  11545. /**
  11546. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11547. */
  11548. isPickable: boolean;
  11549. /**
  11550. * Specifies the rendering group id for this mesh (0 by default)
  11551. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11552. */
  11553. renderingGroupId: number;
  11554. /**
  11555. * Defines the list of sprites managed by the manager.
  11556. */
  11557. sprites: Array<Sprite>;
  11558. /**
  11559. * Tests the intersection of a sprite with a specific ray.
  11560. * @param ray The ray we are sending to test the collision
  11561. * @param camera The camera space we are sending rays in
  11562. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11563. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11564. * @returns picking info or null.
  11565. */
  11566. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11567. /**
  11568. * Renders the list of sprites on screen.
  11569. */
  11570. render(): void;
  11571. }
  11572. /**
  11573. * Class used to manage multiple sprites on the same spritesheet
  11574. * @see http://doc.babylonjs.com/babylon101/sprites
  11575. */
  11576. export class SpriteManager implements ISpriteManager {
  11577. /** defines the manager's name */
  11578. name: string;
  11579. /** Gets the list of sprites */
  11580. sprites: Sprite[];
  11581. /** Gets or sets the rendering group id (0 by default) */
  11582. renderingGroupId: number;
  11583. /** Gets or sets camera layer mask */
  11584. layerMask: number;
  11585. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11586. fogEnabled: boolean;
  11587. /** Gets or sets a boolean indicating if the sprites are pickable */
  11588. isPickable: boolean;
  11589. /** Defines the default width of a cell in the spritesheet */
  11590. cellWidth: number;
  11591. /** Defines the default height of a cell in the spritesheet */
  11592. cellHeight: number;
  11593. /**
  11594. * An event triggered when the manager is disposed.
  11595. */
  11596. onDisposeObservable: Observable<SpriteManager>;
  11597. private _onDisposeObserver;
  11598. /**
  11599. * Callback called when the manager is disposed
  11600. */
  11601. onDispose: () => void;
  11602. private _capacity;
  11603. private _spriteTexture;
  11604. private _epsilon;
  11605. private _scene;
  11606. private _vertexData;
  11607. private _buffer;
  11608. private _vertexBuffers;
  11609. private _indexBuffer;
  11610. private _effectBase;
  11611. private _effectFog;
  11612. /**
  11613. * Gets or sets the spritesheet texture
  11614. */
  11615. texture: Texture;
  11616. /**
  11617. * Creates a new sprite manager
  11618. * @param name defines the manager's name
  11619. * @param imgUrl defines the sprite sheet url
  11620. * @param capacity defines the maximum allowed number of sprites
  11621. * @param cellSize defines the size of a sprite cell
  11622. * @param scene defines the hosting scene
  11623. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11624. * @param samplingMode defines the smapling mode to use with spritesheet
  11625. */
  11626. constructor(
  11627. /** defines the manager's name */
  11628. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11629. private _appendSpriteVertex;
  11630. /**
  11631. * Intersects the sprites with a ray
  11632. * @param ray defines the ray to intersect with
  11633. * @param camera defines the current active camera
  11634. * @param predicate defines a predicate used to select candidate sprites
  11635. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11636. * @returns null if no hit or a PickingInfo
  11637. */
  11638. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11639. /**
  11640. * Render all child sprites
  11641. */
  11642. render(): void;
  11643. /**
  11644. * Release associated resources
  11645. */
  11646. dispose(): void;
  11647. }
  11648. }
  11649. declare module BABYLON {
  11650. /**
  11651. * Class used to represent a sprite
  11652. * @see http://doc.babylonjs.com/babylon101/sprites
  11653. */
  11654. export class Sprite {
  11655. /** defines the name */
  11656. name: string;
  11657. /** Gets or sets the current world position */
  11658. position: Vector3;
  11659. /** Gets or sets the main color */
  11660. color: Color4;
  11661. /** Gets or sets the width */
  11662. width: number;
  11663. /** Gets or sets the height */
  11664. height: number;
  11665. /** Gets or sets rotation angle */
  11666. angle: number;
  11667. /** Gets or sets the cell index in the sprite sheet */
  11668. cellIndex: number;
  11669. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11670. invertU: number;
  11671. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11672. invertV: number;
  11673. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11674. disposeWhenFinishedAnimating: boolean;
  11675. /** Gets the list of attached animations */
  11676. animations: Animation[];
  11677. /** Gets or sets a boolean indicating if the sprite can be picked */
  11678. isPickable: boolean;
  11679. /**
  11680. * Gets or sets the associated action manager
  11681. */
  11682. actionManager: Nullable<ActionManager>;
  11683. private _animationStarted;
  11684. private _loopAnimation;
  11685. private _fromIndex;
  11686. private _toIndex;
  11687. private _delay;
  11688. private _direction;
  11689. private _manager;
  11690. private _time;
  11691. private _onAnimationEnd;
  11692. /**
  11693. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11694. */
  11695. isVisible: boolean;
  11696. /**
  11697. * Gets or sets the sprite size
  11698. */
  11699. size: number;
  11700. /**
  11701. * Creates a new Sprite
  11702. * @param name defines the name
  11703. * @param manager defines the manager
  11704. */
  11705. constructor(
  11706. /** defines the name */
  11707. name: string, manager: ISpriteManager);
  11708. /**
  11709. * Starts an animation
  11710. * @param from defines the initial key
  11711. * @param to defines the end key
  11712. * @param loop defines if the animation must loop
  11713. * @param delay defines the start delay (in ms)
  11714. * @param onAnimationEnd defines a callback to call when animation ends
  11715. */
  11716. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11717. /** Stops current animation (if any) */
  11718. stopAnimation(): void;
  11719. /** @hidden */ animate(deltaTime: number): void;
  11720. /** Release associated resources */
  11721. dispose(): void;
  11722. }
  11723. }
  11724. declare module BABYLON {
  11725. /**
  11726. * Information about the result of picking within a scene
  11727. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11728. */
  11729. export class PickingInfo {
  11730. /** @hidden */ pickingUnavailable: boolean;
  11731. /**
  11732. * If the pick collided with an object
  11733. */
  11734. hit: boolean;
  11735. /**
  11736. * Distance away where the pick collided
  11737. */
  11738. distance: number;
  11739. /**
  11740. * The location of pick collision
  11741. */
  11742. pickedPoint: Nullable<Vector3>;
  11743. /**
  11744. * The mesh corresponding the the pick collision
  11745. */
  11746. pickedMesh: Nullable<AbstractMesh>;
  11747. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11748. bu: number;
  11749. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11750. bv: number;
  11751. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11752. faceId: number;
  11753. /** Id of the the submesh that was picked */
  11754. subMeshId: number;
  11755. /** If a sprite was picked, this will be the sprite the pick collided with */
  11756. pickedSprite: Nullable<Sprite>;
  11757. /**
  11758. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11759. */
  11760. originMesh: Nullable<AbstractMesh>;
  11761. /**
  11762. * The ray that was used to perform the picking.
  11763. */
  11764. ray: Nullable<Ray>;
  11765. /**
  11766. * Gets the normal correspodning to the face the pick collided with
  11767. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11768. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11769. * @returns The normal correspodning to the face the pick collided with
  11770. */
  11771. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11772. /**
  11773. * Gets the texture coordinates of where the pick occured
  11774. * @returns the vector containing the coordnates of the texture
  11775. */
  11776. getTextureCoordinates(): Nullable<Vector2>;
  11777. }
  11778. }
  11779. declare module BABYLON {
  11780. /**
  11781. * Gather the list of pointer event types as constants.
  11782. */
  11783. export class PointerEventTypes {
  11784. /**
  11785. * 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.
  11786. */
  11787. static readonly POINTERDOWN: number;
  11788. /**
  11789. * The pointerup event is fired when a pointer is no longer active.
  11790. */
  11791. static readonly POINTERUP: number;
  11792. /**
  11793. * The pointermove event is fired when a pointer changes coordinates.
  11794. */
  11795. static readonly POINTERMOVE: number;
  11796. /**
  11797. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11798. */
  11799. static readonly POINTERWHEEL: number;
  11800. /**
  11801. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11802. */
  11803. static readonly POINTERPICK: number;
  11804. /**
  11805. * The pointertap event is fired when a the object has been touched and released without drag.
  11806. */
  11807. static readonly POINTERTAP: number;
  11808. /**
  11809. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11810. */
  11811. static readonly POINTERDOUBLETAP: number;
  11812. }
  11813. /**
  11814. * Base class of pointer info types.
  11815. */
  11816. export class PointerInfoBase {
  11817. /**
  11818. * Defines the type of event (PointerEventTypes)
  11819. */
  11820. type: number;
  11821. /**
  11822. * Defines the related dom event
  11823. */
  11824. event: PointerEvent | MouseWheelEvent;
  11825. /**
  11826. * Instantiates the base class of pointers info.
  11827. * @param type Defines the type of event (PointerEventTypes)
  11828. * @param event Defines the related dom event
  11829. */
  11830. constructor(
  11831. /**
  11832. * Defines the type of event (PointerEventTypes)
  11833. */
  11834. type: number,
  11835. /**
  11836. * Defines the related dom event
  11837. */
  11838. event: PointerEvent | MouseWheelEvent);
  11839. }
  11840. /**
  11841. * This class is used to store pointer related info for the onPrePointerObservable event.
  11842. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11843. */
  11844. export class PointerInfoPre extends PointerInfoBase {
  11845. /**
  11846. * Ray from a pointer if availible (eg. 6dof controller)
  11847. */
  11848. ray: Nullable<Ray>;
  11849. /**
  11850. * Defines the local position of the pointer on the canvas.
  11851. */
  11852. localPosition: Vector2;
  11853. /**
  11854. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11855. */
  11856. skipOnPointerObservable: boolean;
  11857. /**
  11858. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11859. * @param type Defines the type of event (PointerEventTypes)
  11860. * @param event Defines the related dom event
  11861. * @param localX Defines the local x coordinates of the pointer when the event occured
  11862. * @param localY Defines the local y coordinates of the pointer when the event occured
  11863. */
  11864. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11865. }
  11866. /**
  11867. * This type contains all the data related to a pointer event in Babylon.js.
  11868. * 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.
  11869. */
  11870. export class PointerInfo extends PointerInfoBase {
  11871. /**
  11872. * Defines the picking info associated to the info (if any)\
  11873. */
  11874. pickInfo: Nullable<PickingInfo>;
  11875. /**
  11876. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11877. * @param type Defines the type of event (PointerEventTypes)
  11878. * @param event Defines the related dom event
  11879. * @param pickInfo Defines the picking info associated to the info (if any)\
  11880. */
  11881. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11882. /**
  11883. * Defines the picking info associated to the info (if any)\
  11884. */
  11885. pickInfo: Nullable<PickingInfo>);
  11886. }
  11887. /**
  11888. * Data relating to a touch event on the screen.
  11889. */
  11890. export interface PointerTouch {
  11891. /**
  11892. * X coordinate of touch.
  11893. */
  11894. x: number;
  11895. /**
  11896. * Y coordinate of touch.
  11897. */
  11898. y: number;
  11899. /**
  11900. * Id of touch. Unique for each finger.
  11901. */
  11902. pointerId: number;
  11903. /**
  11904. * Event type passed from DOM.
  11905. */
  11906. type: any;
  11907. }
  11908. }
  11909. declare module BABYLON {
  11910. /**
  11911. * Manage the mouse inputs to control the movement of a free camera.
  11912. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11913. */
  11914. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11915. /**
  11916. * Define if touch is enabled in the mouse input
  11917. */
  11918. touchEnabled: boolean;
  11919. /**
  11920. * Defines the camera the input is attached to.
  11921. */
  11922. camera: FreeCamera;
  11923. /**
  11924. * Defines the buttons associated with the input to handle camera move.
  11925. */
  11926. buttons: number[];
  11927. /**
  11928. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11929. */
  11930. angularSensibility: number;
  11931. private _pointerInput;
  11932. private _onMouseMove;
  11933. private _observer;
  11934. private previousPosition;
  11935. /**
  11936. * Observable for when a pointer move event occurs containing the move offset
  11937. */
  11938. onPointerMovedObservable: Observable<{
  11939. offsetX: number;
  11940. offsetY: number;
  11941. }>;
  11942. /**
  11943. * @hidden
  11944. * If the camera should be rotated automatically based on pointer movement
  11945. */ allowCameraRotation: boolean;
  11946. /**
  11947. * Manage the mouse inputs to control the movement of a free camera.
  11948. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11949. * @param touchEnabled Defines if touch is enabled or not
  11950. */
  11951. constructor(
  11952. /**
  11953. * Define if touch is enabled in the mouse input
  11954. */
  11955. touchEnabled?: boolean);
  11956. /**
  11957. * Attach the input controls to a specific dom element to get the input from.
  11958. * @param element Defines the element the controls should be listened from
  11959. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11960. */
  11961. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11962. /**
  11963. * Called on JS contextmenu event.
  11964. * Override this method to provide functionality.
  11965. */
  11966. protected onContextMenu(evt: PointerEvent): void;
  11967. /**
  11968. * Detach the current controls from the specified dom element.
  11969. * @param element Defines the element to stop listening the inputs from
  11970. */
  11971. detachControl(element: Nullable<HTMLElement>): void;
  11972. /**
  11973. * Gets the class name of the current intput.
  11974. * @returns the class name
  11975. */
  11976. getClassName(): string;
  11977. /**
  11978. * Get the friendly name associated with the input class.
  11979. * @returns the input friendly name
  11980. */
  11981. getSimpleName(): string;
  11982. }
  11983. }
  11984. declare module BABYLON {
  11985. /**
  11986. * Manage the touch inputs to control the movement of a free camera.
  11987. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11988. */
  11989. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11990. /**
  11991. * Defines the camera the input is attached to.
  11992. */
  11993. camera: FreeCamera;
  11994. /**
  11995. * Defines the touch sensibility for rotation.
  11996. * The higher the faster.
  11997. */
  11998. touchAngularSensibility: number;
  11999. /**
  12000. * Defines the touch sensibility for move.
  12001. * The higher the faster.
  12002. */
  12003. touchMoveSensibility: number;
  12004. private _offsetX;
  12005. private _offsetY;
  12006. private _pointerPressed;
  12007. private _pointerInput;
  12008. private _observer;
  12009. private _onLostFocus;
  12010. /**
  12011. * Attach the input controls to a specific dom element to get the input from.
  12012. * @param element Defines the element the controls should be listened from
  12013. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12014. */
  12015. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12016. /**
  12017. * Detach the current controls from the specified dom element.
  12018. * @param element Defines the element to stop listening the inputs from
  12019. */
  12020. detachControl(element: Nullable<HTMLElement>): void;
  12021. /**
  12022. * Update the current camera state depending on the inputs that have been used this frame.
  12023. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12024. */
  12025. checkInputs(): void;
  12026. /**
  12027. * Gets the class name of the current intput.
  12028. * @returns the class name
  12029. */
  12030. getClassName(): string;
  12031. /**
  12032. * Get the friendly name associated with the input class.
  12033. * @returns the input friendly name
  12034. */
  12035. getSimpleName(): string;
  12036. }
  12037. }
  12038. declare module BABYLON {
  12039. /**
  12040. * Default Inputs manager for the FreeCamera.
  12041. * It groups all the default supported inputs for ease of use.
  12042. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12043. */
  12044. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12045. /**
  12046. * @hidden
  12047. */ keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12048. /**
  12049. * @hidden
  12050. */ mouseInput: Nullable<FreeCameraMouseInput>;
  12051. /**
  12052. * Instantiates a new FreeCameraInputsManager.
  12053. * @param camera Defines the camera the inputs belong to
  12054. */
  12055. constructor(camera: FreeCamera);
  12056. /**
  12057. * Add keyboard input support to the input manager.
  12058. * @returns the current input manager
  12059. */
  12060. addKeyboard(): FreeCameraInputsManager;
  12061. /**
  12062. * Add mouse input support to the input manager.
  12063. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12064. * @returns the current input manager
  12065. */
  12066. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12067. /**
  12068. * Removes the mouse input support from the manager
  12069. * @returns the current input manager
  12070. */
  12071. removeMouse(): FreeCameraInputsManager;
  12072. /**
  12073. * Add touch input support to the input manager.
  12074. * @returns the current input manager
  12075. */
  12076. addTouch(): FreeCameraInputsManager;
  12077. }
  12078. }
  12079. declare module BABYLON {
  12080. /**
  12081. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12082. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12083. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12084. */
  12085. export class FreeCamera extends TargetCamera {
  12086. /**
  12087. * Define the collision ellipsoid of the camera.
  12088. * This is helpful to simulate a camera body like the player body around the camera
  12089. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12090. */
  12091. ellipsoid: Vector3;
  12092. /**
  12093. * Define an offset for the position of the ellipsoid around the camera.
  12094. * This can be helpful to determine the center of the body near the gravity center of the body
  12095. * instead of its head.
  12096. */
  12097. ellipsoidOffset: Vector3;
  12098. /**
  12099. * Enable or disable collisions of the camera with the rest of the scene objects.
  12100. */
  12101. checkCollisions: boolean;
  12102. /**
  12103. * Enable or disable gravity on the camera.
  12104. */
  12105. applyGravity: boolean;
  12106. /**
  12107. * Define the input manager associated to the camera.
  12108. */
  12109. inputs: FreeCameraInputsManager;
  12110. /**
  12111. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12112. * Higher values reduce sensitivity.
  12113. */
  12114. /**
  12115. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12116. * Higher values reduce sensitivity.
  12117. */
  12118. angularSensibility: number;
  12119. /**
  12120. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12121. */
  12122. keysUp: number[];
  12123. /**
  12124. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12125. */
  12126. keysDown: number[];
  12127. /**
  12128. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12129. */
  12130. keysLeft: number[];
  12131. /**
  12132. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12133. */
  12134. keysRight: number[];
  12135. /**
  12136. * Event raised when the camera collide with a mesh in the scene.
  12137. */
  12138. onCollide: (collidedMesh: AbstractMesh) => void;
  12139. private _collider;
  12140. private _needMoveForGravity;
  12141. private _oldPosition;
  12142. private _diffPosition;
  12143. private _newPosition;
  12144. /** @hidden */ localDirection: Vector3;
  12145. /** @hidden */ transformedDirection: Vector3;
  12146. /**
  12147. * Instantiates a Free Camera.
  12148. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12149. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12150. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12151. * @param name Define the name of the camera in the scene
  12152. * @param position Define the start position of the camera in the scene
  12153. * @param scene Define the scene the camera belongs to
  12154. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12155. */
  12156. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12157. /**
  12158. * Attached controls to the current camera.
  12159. * @param element Defines the element the controls should be listened from
  12160. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12161. */
  12162. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12163. /**
  12164. * Detach the current controls from the camera.
  12165. * The camera will stop reacting to inputs.
  12166. * @param element Defines the element to stop listening the inputs from
  12167. */
  12168. detachControl(element: HTMLElement): void;
  12169. private _collisionMask;
  12170. /**
  12171. * Define a collision mask to limit the list of object the camera can collide with
  12172. */
  12173. collisionMask: number;
  12174. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  12175. private _onCollisionPositionChange;
  12176. /** @hidden */ checkInputs(): void;
  12177. /** @hidden */ decideIfNeedsToMove(): boolean;
  12178. /** @hidden */ updatePosition(): void;
  12179. /**
  12180. * Destroy the camera and release the current resources hold by it.
  12181. */
  12182. dispose(): void;
  12183. /**
  12184. * Gets the current object class name.
  12185. * @return the class name
  12186. */
  12187. getClassName(): string;
  12188. }
  12189. }
  12190. declare module BABYLON {
  12191. /**
  12192. * Represents a gamepad control stick position
  12193. */
  12194. export class StickValues {
  12195. /**
  12196. * The x component of the control stick
  12197. */
  12198. x: number;
  12199. /**
  12200. * The y component of the control stick
  12201. */
  12202. y: number;
  12203. /**
  12204. * Initializes the gamepad x and y control stick values
  12205. * @param x The x component of the gamepad control stick value
  12206. * @param y The y component of the gamepad control stick value
  12207. */
  12208. constructor(
  12209. /**
  12210. * The x component of the control stick
  12211. */
  12212. x: number,
  12213. /**
  12214. * The y component of the control stick
  12215. */
  12216. y: number);
  12217. }
  12218. /**
  12219. * An interface which manages callbacks for gamepad button changes
  12220. */
  12221. export interface GamepadButtonChanges {
  12222. /**
  12223. * Called when a gamepad has been changed
  12224. */
  12225. changed: boolean;
  12226. /**
  12227. * Called when a gamepad press event has been triggered
  12228. */
  12229. pressChanged: boolean;
  12230. /**
  12231. * Called when a touch event has been triggered
  12232. */
  12233. touchChanged: boolean;
  12234. /**
  12235. * Called when a value has changed
  12236. */
  12237. valueChanged: boolean;
  12238. }
  12239. /**
  12240. * Represents a gamepad
  12241. */
  12242. export class Gamepad {
  12243. /**
  12244. * The id of the gamepad
  12245. */
  12246. id: string;
  12247. /**
  12248. * The index of the gamepad
  12249. */
  12250. index: number;
  12251. /**
  12252. * The browser gamepad
  12253. */
  12254. browserGamepad: any;
  12255. /**
  12256. * Specifies what type of gamepad this represents
  12257. */
  12258. type: number;
  12259. private _leftStick;
  12260. private _rightStick;
  12261. /** @hidden */ isConnected: boolean;
  12262. private _leftStickAxisX;
  12263. private _leftStickAxisY;
  12264. private _rightStickAxisX;
  12265. private _rightStickAxisY;
  12266. /**
  12267. * Triggered when the left control stick has been changed
  12268. */
  12269. private _onleftstickchanged;
  12270. /**
  12271. * Triggered when the right control stick has been changed
  12272. */
  12273. private _onrightstickchanged;
  12274. /**
  12275. * Represents a gamepad controller
  12276. */
  12277. static GAMEPAD: number;
  12278. /**
  12279. * Represents a generic controller
  12280. */
  12281. static GENERIC: number;
  12282. /**
  12283. * Represents an XBox controller
  12284. */
  12285. static XBOX: number;
  12286. /**
  12287. * Represents a pose-enabled controller
  12288. */
  12289. static POSE_ENABLED: number;
  12290. /**
  12291. * Specifies whether the left control stick should be Y-inverted
  12292. */
  12293. protected _invertLeftStickY: boolean;
  12294. /**
  12295. * Specifies if the gamepad has been connected
  12296. */
  12297. readonly isConnected: boolean;
  12298. /**
  12299. * Initializes the gamepad
  12300. * @param id The id of the gamepad
  12301. * @param index The index of the gamepad
  12302. * @param browserGamepad The browser gamepad
  12303. * @param leftStickX The x component of the left joystick
  12304. * @param leftStickY The y component of the left joystick
  12305. * @param rightStickX The x component of the right joystick
  12306. * @param rightStickY The y component of the right joystick
  12307. */
  12308. constructor(
  12309. /**
  12310. * The id of the gamepad
  12311. */
  12312. id: string,
  12313. /**
  12314. * The index of the gamepad
  12315. */
  12316. index: number,
  12317. /**
  12318. * The browser gamepad
  12319. */
  12320. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12321. /**
  12322. * Callback triggered when the left joystick has changed
  12323. * @param callback
  12324. */
  12325. onleftstickchanged(callback: (values: StickValues) => void): void;
  12326. /**
  12327. * Callback triggered when the right joystick has changed
  12328. * @param callback
  12329. */
  12330. onrightstickchanged(callback: (values: StickValues) => void): void;
  12331. /**
  12332. * Gets the left joystick
  12333. */
  12334. /**
  12335. * Sets the left joystick values
  12336. */
  12337. leftStick: StickValues;
  12338. /**
  12339. * Gets the right joystick
  12340. */
  12341. /**
  12342. * Sets the right joystick value
  12343. */
  12344. rightStick: StickValues;
  12345. /**
  12346. * Updates the gamepad joystick positions
  12347. */
  12348. update(): void;
  12349. /**
  12350. * Disposes the gamepad
  12351. */
  12352. dispose(): void;
  12353. }
  12354. /**
  12355. * Represents a generic gamepad
  12356. */
  12357. export class GenericPad extends Gamepad {
  12358. private _buttons;
  12359. private _onbuttondown;
  12360. private _onbuttonup;
  12361. /**
  12362. * Observable triggered when a button has been pressed
  12363. */
  12364. onButtonDownObservable: Observable<number>;
  12365. /**
  12366. * Observable triggered when a button has been released
  12367. */
  12368. onButtonUpObservable: Observable<number>;
  12369. /**
  12370. * Callback triggered when a button has been pressed
  12371. * @param callback Called when a button has been pressed
  12372. */
  12373. onbuttondown(callback: (buttonPressed: number) => void): void;
  12374. /**
  12375. * Callback triggered when a button has been released
  12376. * @param callback Called when a button has been released
  12377. */
  12378. onbuttonup(callback: (buttonReleased: number) => void): void;
  12379. /**
  12380. * Initializes the generic gamepad
  12381. * @param id The id of the generic gamepad
  12382. * @param index The index of the generic gamepad
  12383. * @param browserGamepad The browser gamepad
  12384. */
  12385. constructor(id: string, index: number, browserGamepad: any);
  12386. private _setButtonValue;
  12387. /**
  12388. * Updates the generic gamepad
  12389. */
  12390. update(): void;
  12391. /**
  12392. * Disposes the generic gamepad
  12393. */
  12394. dispose(): void;
  12395. }
  12396. }
  12397. declare module BABYLON {
  12398. /**
  12399. * Defines the types of pose enabled controllers that are supported
  12400. */
  12401. export enum PoseEnabledControllerType {
  12402. /**
  12403. * HTC Vive
  12404. */
  12405. VIVE = 0,
  12406. /**
  12407. * Oculus Rift
  12408. */
  12409. OCULUS = 1,
  12410. /**
  12411. * Windows mixed reality
  12412. */
  12413. WINDOWS = 2,
  12414. /**
  12415. * Samsung gear VR
  12416. */
  12417. GEAR_VR = 3,
  12418. /**
  12419. * Google Daydream
  12420. */
  12421. DAYDREAM = 4,
  12422. /**
  12423. * Generic
  12424. */
  12425. GENERIC = 5
  12426. }
  12427. /**
  12428. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12429. */
  12430. export interface MutableGamepadButton {
  12431. /**
  12432. * Value of the button/trigger
  12433. */
  12434. value: number;
  12435. /**
  12436. * If the button/trigger is currently touched
  12437. */
  12438. touched: boolean;
  12439. /**
  12440. * If the button/trigger is currently pressed
  12441. */
  12442. pressed: boolean;
  12443. }
  12444. /**
  12445. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12446. * @hidden
  12447. */
  12448. export interface ExtendedGamepadButton extends GamepadButton {
  12449. /**
  12450. * If the button/trigger is currently pressed
  12451. */
  12452. readonly pressed: boolean;
  12453. /**
  12454. * If the button/trigger is currently touched
  12455. */
  12456. readonly touched: boolean;
  12457. /**
  12458. * Value of the button/trigger
  12459. */
  12460. readonly value: number;
  12461. }
  12462. /** @hidden */
  12463. export interface _GamePadFactory {
  12464. /**
  12465. * Returns wether or not the current gamepad can be created for this type of controller.
  12466. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12467. * @returns true if it can be created, otherwise false
  12468. */
  12469. canCreate(gamepadInfo: any): boolean;
  12470. /**
  12471. * Creates a new instance of the Gamepad.
  12472. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12473. * @returns the new gamepad instance
  12474. */
  12475. create(gamepadInfo: any): Gamepad;
  12476. }
  12477. /**
  12478. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12479. */
  12480. export class PoseEnabledControllerHelper {
  12481. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  12482. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12483. /**
  12484. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12485. * @param vrGamepad the gamepad to initialized
  12486. * @returns a vr controller of the type the gamepad identified as
  12487. */
  12488. static InitiateController(vrGamepad: any): Gamepad;
  12489. }
  12490. /**
  12491. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12492. */
  12493. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12494. private _deviceRoomPosition;
  12495. private _deviceRoomRotationQuaternion;
  12496. /**
  12497. * The device position in babylon space
  12498. */
  12499. devicePosition: Vector3;
  12500. /**
  12501. * The device rotation in babylon space
  12502. */
  12503. deviceRotationQuaternion: Quaternion;
  12504. /**
  12505. * The scale factor of the device in babylon space
  12506. */
  12507. deviceScaleFactor: number;
  12508. /**
  12509. * (Likely devicePosition should be used instead) The device position in its room space
  12510. */
  12511. position: Vector3;
  12512. /**
  12513. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12514. */
  12515. rotationQuaternion: Quaternion;
  12516. /**
  12517. * The type of controller (Eg. Windows mixed reality)
  12518. */
  12519. controllerType: PoseEnabledControllerType;
  12520. protected _calculatedPosition: Vector3;
  12521. private _calculatedRotation;
  12522. /**
  12523. * The raw pose from the device
  12524. */
  12525. rawPose: DevicePose;
  12526. private _trackPosition;
  12527. private _maxRotationDistFromHeadset;
  12528. private _draggedRoomRotation;
  12529. /**
  12530. * @hidden
  12531. */ disableTrackPosition(fixedPosition: Vector3): void;
  12532. /**
  12533. * Internal, the mesh attached to the controller
  12534. * @hidden
  12535. */ mesh: Nullable<AbstractMesh>;
  12536. private _poseControlledCamera;
  12537. private _leftHandSystemQuaternion;
  12538. /**
  12539. * Internal, matrix used to convert room space to babylon space
  12540. * @hidden
  12541. */ deviceToWorld: Matrix;
  12542. /**
  12543. * Node to be used when casting a ray from the controller
  12544. * @hidden
  12545. */ pointingPoseNode: Nullable<TransformNode>;
  12546. /**
  12547. * Name of the child mesh that can be used to cast a ray from the controller
  12548. */
  12549. static readonly POINTING_POSE: string;
  12550. /**
  12551. * Creates a new PoseEnabledController from a gamepad
  12552. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12553. */
  12554. constructor(browserGamepad: any);
  12555. private _workingMatrix;
  12556. /**
  12557. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12558. */
  12559. update(): void;
  12560. /**
  12561. * Updates only the pose device and mesh without doing any button event checking
  12562. */
  12563. protected _updatePoseAndMesh(): void;
  12564. /**
  12565. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12566. * @param poseData raw pose fromthe device
  12567. */
  12568. updateFromDevice(poseData: DevicePose): void;
  12569. /**
  12570. * @hidden
  12571. */ meshAttachedObservable: Observable<AbstractMesh>;
  12572. /**
  12573. * Attaches a mesh to the controller
  12574. * @param mesh the mesh to be attached
  12575. */
  12576. attachToMesh(mesh: AbstractMesh): void;
  12577. /**
  12578. * Attaches the controllers mesh to a camera
  12579. * @param camera the camera the mesh should be attached to
  12580. */
  12581. attachToPoseControlledCamera(camera: TargetCamera): void;
  12582. /**
  12583. * Disposes of the controller
  12584. */
  12585. dispose(): void;
  12586. /**
  12587. * The mesh that is attached to the controller
  12588. */
  12589. readonly mesh: Nullable<AbstractMesh>;
  12590. /**
  12591. * Gets the ray of the controller in the direction the controller is pointing
  12592. * @param length the length the resulting ray should be
  12593. * @returns a ray in the direction the controller is pointing
  12594. */
  12595. getForwardRay(length?: number): Ray;
  12596. }
  12597. }
  12598. declare module BABYLON {
  12599. /**
  12600. * Defines the WebVRController object that represents controllers tracked in 3D space
  12601. */
  12602. export abstract class WebVRController extends PoseEnabledController {
  12603. /**
  12604. * Internal, the default controller model for the controller
  12605. */
  12606. protected _defaultModel: AbstractMesh;
  12607. /**
  12608. * Fired when the trigger state has changed
  12609. */
  12610. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12611. /**
  12612. * Fired when the main button state has changed
  12613. */
  12614. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12615. /**
  12616. * Fired when the secondary button state has changed
  12617. */
  12618. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12619. /**
  12620. * Fired when the pad state has changed
  12621. */
  12622. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12623. /**
  12624. * Fired when controllers stick values have changed
  12625. */
  12626. onPadValuesChangedObservable: Observable<StickValues>;
  12627. /**
  12628. * Array of button availible on the controller
  12629. */
  12630. protected _buttons: Array<MutableGamepadButton>;
  12631. private _onButtonStateChange;
  12632. /**
  12633. * Fired when a controller button's state has changed
  12634. * @param callback the callback containing the button that was modified
  12635. */
  12636. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12637. /**
  12638. * X and Y axis corrisponding to the controllers joystick
  12639. */
  12640. pad: StickValues;
  12641. /**
  12642. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12643. */
  12644. hand: string;
  12645. /**
  12646. * The default controller model for the controller
  12647. */
  12648. readonly defaultModel: AbstractMesh;
  12649. /**
  12650. * Creates a new WebVRController from a gamepad
  12651. * @param vrGamepad the gamepad that the WebVRController should be created from
  12652. */
  12653. constructor(vrGamepad: any);
  12654. /**
  12655. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12656. */
  12657. update(): void;
  12658. /**
  12659. * Function to be called when a button is modified
  12660. */
  12661. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12662. /**
  12663. * Loads a mesh and attaches it to the controller
  12664. * @param scene the scene the mesh should be added to
  12665. * @param meshLoaded callback for when the mesh has been loaded
  12666. */
  12667. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12668. private _setButtonValue;
  12669. private _changes;
  12670. private _checkChanges;
  12671. /**
  12672. * Disposes of th webVRCOntroller
  12673. */
  12674. dispose(): void;
  12675. }
  12676. }
  12677. declare module BABYLON {
  12678. /**
  12679. * The HemisphericLight simulates the ambient environment light,
  12680. * so the passed direction is the light reflection direction, not the incoming direction.
  12681. */
  12682. export class HemisphericLight extends Light {
  12683. /**
  12684. * The groundColor is the light in the opposite direction to the one specified during creation.
  12685. * 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.
  12686. */
  12687. groundColor: Color3;
  12688. /**
  12689. * The light reflection direction, not the incoming direction.
  12690. */
  12691. direction: Vector3;
  12692. /**
  12693. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12694. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12695. * The HemisphericLight can't cast shadows.
  12696. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12697. * @param name The friendly name of the light
  12698. * @param direction The direction of the light reflection
  12699. * @param scene The scene the light belongs to
  12700. */
  12701. constructor(name: string, direction: Vector3, scene: Scene);
  12702. protected _buildUniformLayout(): void;
  12703. /**
  12704. * Returns the string "HemisphericLight".
  12705. * @return The class name
  12706. */
  12707. getClassName(): string;
  12708. /**
  12709. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12710. * Returns the updated direction.
  12711. * @param target The target the direction should point to
  12712. * @return The computed direction
  12713. */
  12714. setDirectionToTarget(target: Vector3): Vector3;
  12715. /**
  12716. * Returns the shadow generator associated to the light.
  12717. * @returns Always null for hemispheric lights because it does not support shadows.
  12718. */
  12719. getShadowGenerator(): Nullable<IShadowGenerator>;
  12720. /**
  12721. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12722. * @param effect The effect to update
  12723. * @param lightIndex The index of the light in the effect to update
  12724. * @returns The hemispheric light
  12725. */
  12726. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12727. /**
  12728. * Computes the world matrix of the node
  12729. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12730. * @param useWasUpdatedFlag defines a reserved property
  12731. * @returns the world matrix
  12732. */
  12733. computeWorldMatrix(): Matrix;
  12734. /**
  12735. * Returns the integer 3.
  12736. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12737. */
  12738. getTypeID(): number;
  12739. /**
  12740. * Prepares the list of defines specific to the light type.
  12741. * @param defines the list of defines
  12742. * @param lightIndex defines the index of the light for the effect
  12743. */
  12744. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12745. }
  12746. }
  12747. declare module BABYLON {
  12748. /** @hidden */
  12749. export var vrMultiviewToSingleviewPixelShader: {
  12750. name: string;
  12751. shader: string;
  12752. };
  12753. }
  12754. declare module BABYLON {
  12755. /**
  12756. * Renders to multiple views with a single draw call
  12757. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  12758. */
  12759. export class MultiviewRenderTarget extends RenderTargetTexture {
  12760. /**
  12761. * Creates a multiview render target
  12762. * @param scene scene used with the render target
  12763. * @param size the size of the render target (used for each view)
  12764. */
  12765. constructor(scene: Scene, size?: number | {
  12766. width: number;
  12767. height: number;
  12768. } | {
  12769. ratio: number;
  12770. });
  12771. /**
  12772. * @hidden
  12773. * @param faceIndex the face index, if its a cube texture
  12774. */ bindFrameBuffer(faceIndex?: number): void;
  12775. /**
  12776. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  12777. * @returns the view count
  12778. */
  12779. getViewCount(): number;
  12780. }
  12781. }
  12782. declare module BABYLON {
  12783. interface Engine {
  12784. /**
  12785. * Creates a new multiview render target
  12786. * @param width defines the width of the texture
  12787. * @param height defines the height of the texture
  12788. * @returns the created multiview texture
  12789. */
  12790. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  12791. /**
  12792. * Binds a multiview framebuffer to be drawn to
  12793. * @param multiviewTexture texture to bind
  12794. */
  12795. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  12796. }
  12797. interface Camera {
  12798. /**
  12799. * @hidden
  12800. * 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)
  12801. */ useMultiviewToSingleView: boolean;
  12802. /**
  12803. * @hidden
  12804. * 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)
  12805. */ multiviewTexture: Nullable<RenderTargetTexture>;
  12806. /**
  12807. * @hidden
  12808. * ensures the multiview texture of the camera exists and has the specified width/height
  12809. * @param width height to set on the multiview texture
  12810. * @param height width to set on the multiview texture
  12811. */ resizeOrCreateMultiviewTexture(width: number, height: number): void;
  12812. }
  12813. interface Scene {
  12814. /** @hidden */ transformMatrixR: Matrix;
  12815. /** @hidden */ multiviewSceneUbo: Nullable<UniformBuffer>;
  12816. /** @hidden */ createMultiviewUbo(): void;
  12817. /** @hidden */ updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  12818. /** @hidden */ renderMultiviewToSingleView(camera: Camera): void;
  12819. }
  12820. }
  12821. declare module BABYLON {
  12822. /**
  12823. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  12824. * This will not be used for webXR as it supports displaying texture arrays directly
  12825. */
  12826. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  12827. /**
  12828. * Initializes a VRMultiviewToSingleview
  12829. * @param name name of the post process
  12830. * @param camera camera to be applied to
  12831. * @param scaleFactor scaling factor to the size of the output texture
  12832. */
  12833. constructor(name: string, camera: Camera, scaleFactor: number);
  12834. }
  12835. }
  12836. declare module BABYLON {
  12837. /**
  12838. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12839. * IMPORTANT!! The data is right-hand data.
  12840. * @export
  12841. * @interface DevicePose
  12842. */
  12843. export interface DevicePose {
  12844. /**
  12845. * The position of the device, values in array are [x,y,z].
  12846. */
  12847. readonly position: Nullable<Float32Array>;
  12848. /**
  12849. * The linearVelocity of the device, values in array are [x,y,z].
  12850. */
  12851. readonly linearVelocity: Nullable<Float32Array>;
  12852. /**
  12853. * The linearAcceleration of the device, values in array are [x,y,z].
  12854. */
  12855. readonly linearAcceleration: Nullable<Float32Array>;
  12856. /**
  12857. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  12858. */
  12859. readonly orientation: Nullable<Float32Array>;
  12860. /**
  12861. * The angularVelocity of the device, values in array are [x,y,z].
  12862. */
  12863. readonly angularVelocity: Nullable<Float32Array>;
  12864. /**
  12865. * The angularAcceleration of the device, values in array are [x,y,z].
  12866. */
  12867. readonly angularAcceleration: Nullable<Float32Array>;
  12868. }
  12869. /**
  12870. * Interface representing a pose controlled object in Babylon.
  12871. * A pose controlled object has both regular pose values as well as pose values
  12872. * from an external device such as a VR head mounted display
  12873. */
  12874. export interface PoseControlled {
  12875. /**
  12876. * The position of the object in babylon space.
  12877. */
  12878. position: Vector3;
  12879. /**
  12880. * The rotation quaternion of the object in babylon space.
  12881. */
  12882. rotationQuaternion: Quaternion;
  12883. /**
  12884. * The position of the device in babylon space.
  12885. */
  12886. devicePosition?: Vector3;
  12887. /**
  12888. * The rotation quaternion of the device in babylon space.
  12889. */
  12890. deviceRotationQuaternion: Quaternion;
  12891. /**
  12892. * The raw pose coming from the device.
  12893. */
  12894. rawPose: Nullable<DevicePose>;
  12895. /**
  12896. * The scale of the device to be used when translating from device space to babylon space.
  12897. */
  12898. deviceScaleFactor: number;
  12899. /**
  12900. * Updates the poseControlled values based on the input device pose.
  12901. * @param poseData the pose data to update the object with
  12902. */
  12903. updateFromDevice(poseData: DevicePose): void;
  12904. }
  12905. /**
  12906. * Set of options to customize the webVRCamera
  12907. */
  12908. export interface WebVROptions {
  12909. /**
  12910. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  12911. */
  12912. trackPosition?: boolean;
  12913. /**
  12914. * Sets the scale of the vrDevice in babylon space. (default: 1)
  12915. */
  12916. positionScale?: number;
  12917. /**
  12918. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  12919. */
  12920. displayName?: string;
  12921. /**
  12922. * Should the native controller meshes be initialized. (default: true)
  12923. */
  12924. controllerMeshes?: boolean;
  12925. /**
  12926. * Creating a default HemiLight only on controllers. (default: true)
  12927. */
  12928. defaultLightingOnControllers?: boolean;
  12929. /**
  12930. * If you don't want to use the default VR button of the helper. (default: false)
  12931. */
  12932. useCustomVRButton?: boolean;
  12933. /**
  12934. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  12935. */
  12936. customVRButton?: HTMLButtonElement;
  12937. /**
  12938. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  12939. */
  12940. rayLength?: number;
  12941. /**
  12942. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  12943. */
  12944. defaultHeight?: number;
  12945. /**
  12946. * If multiview should be used if availible (default: false)
  12947. */
  12948. useMultiview?: boolean;
  12949. }
  12950. /**
  12951. * This represents a WebVR camera.
  12952. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  12953. * @example http://doc.babylonjs.com/how_to/webvr_camera
  12954. */
  12955. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  12956. private webVROptions;
  12957. /**
  12958. * @hidden
  12959. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  12960. */ vrDevice: any;
  12961. /**
  12962. * The rawPose of the vrDevice.
  12963. */
  12964. rawPose: Nullable<DevicePose>;
  12965. private _onVREnabled;
  12966. private _specsVersion;
  12967. private _attached;
  12968. private _frameData;
  12969. protected _descendants: Array<Node>;
  12970. private _deviceRoomPosition;
  12971. /** @hidden */ deviceRoomRotationQuaternion: Quaternion;
  12972. private _standingMatrix;
  12973. /**
  12974. * Represents device position in babylon space.
  12975. */
  12976. devicePosition: Vector3;
  12977. /**
  12978. * Represents device rotation in babylon space.
  12979. */
  12980. deviceRotationQuaternion: Quaternion;
  12981. /**
  12982. * The scale of the device to be used when translating from device space to babylon space.
  12983. */
  12984. deviceScaleFactor: number;
  12985. private _deviceToWorld;
  12986. private _worldToDevice;
  12987. /**
  12988. * References to the webVR controllers for the vrDevice.
  12989. */
  12990. controllers: Array<WebVRController>;
  12991. /**
  12992. * Emits an event when a controller is attached.
  12993. */
  12994. onControllersAttachedObservable: Observable<WebVRController[]>;
  12995. /**
  12996. * Emits an event when a controller's mesh has been loaded;
  12997. */
  12998. onControllerMeshLoadedObservable: Observable<WebVRController>;
  12999. /**
  13000. * Emits an event when the HMD's pose has been updated.
  13001. */
  13002. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13003. private _poseSet;
  13004. /**
  13005. * If the rig cameras be used as parent instead of this camera.
  13006. */
  13007. rigParenting: boolean;
  13008. private _lightOnControllers;
  13009. private _defaultHeight?;
  13010. /**
  13011. * Instantiates a WebVRFreeCamera.
  13012. * @param name The name of the WebVRFreeCamera
  13013. * @param position The starting anchor position for the camera
  13014. * @param scene The scene the camera belongs to
  13015. * @param webVROptions a set of customizable options for the webVRCamera
  13016. */
  13017. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13018. /**
  13019. * Gets the device distance from the ground in meters.
  13020. * @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.
  13021. */
  13022. deviceDistanceToRoomGround(): number;
  13023. /**
  13024. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13025. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13026. */
  13027. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13028. /**
  13029. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13030. * @returns A promise with a boolean set to if the standing matrix is supported.
  13031. */
  13032. useStandingMatrixAsync(): Promise<boolean>;
  13033. /**
  13034. * Disposes the camera
  13035. */
  13036. dispose(): void;
  13037. /**
  13038. * Gets a vrController by name.
  13039. * @param name The name of the controller to retreive
  13040. * @returns the controller matching the name specified or null if not found
  13041. */
  13042. getControllerByName(name: string): Nullable<WebVRController>;
  13043. private _leftController;
  13044. /**
  13045. * The controller corrisponding to the users left hand.
  13046. */
  13047. readonly leftController: Nullable<WebVRController>;
  13048. private _rightController;
  13049. /**
  13050. * The controller corrisponding to the users right hand.
  13051. */
  13052. readonly rightController: Nullable<WebVRController>;
  13053. /**
  13054. * Casts a ray forward from the vrCamera's gaze.
  13055. * @param length Length of the ray (default: 100)
  13056. * @returns the ray corrisponding to the gaze
  13057. */
  13058. getForwardRay(length?: number): Ray;
  13059. /**
  13060. * @hidden
  13061. * Updates the camera based on device's frame data
  13062. */ checkInputs(): void;
  13063. /**
  13064. * Updates the poseControlled values based on the input device pose.
  13065. * @param poseData Pose coming from the device
  13066. */
  13067. updateFromDevice(poseData: DevicePose): void;
  13068. private _htmlElementAttached;
  13069. private _detachIfAttached;
  13070. /**
  13071. * WebVR's attach control will start broadcasting frames to the device.
  13072. * Note that in certain browsers (chrome for example) this function must be called
  13073. * within a user-interaction callback. Example:
  13074. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13075. *
  13076. * @param element html element to attach the vrDevice to
  13077. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13078. */
  13079. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13080. /**
  13081. * Detaches the camera from the html element and disables VR
  13082. *
  13083. * @param element html element to detach from
  13084. */
  13085. detachControl(element: HTMLElement): void;
  13086. /**
  13087. * @returns the name of this class
  13088. */
  13089. getClassName(): string;
  13090. /**
  13091. * Calls resetPose on the vrDisplay
  13092. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13093. */
  13094. resetToCurrentRotation(): void;
  13095. /**
  13096. * @hidden
  13097. * Updates the rig cameras (left and right eye)
  13098. */ updateRigCameras(): void;
  13099. private _workingVector;
  13100. private _oneVector;
  13101. private _workingMatrix;
  13102. private updateCacheCalled;
  13103. private _correctPositionIfNotTrackPosition;
  13104. /**
  13105. * @hidden
  13106. * Updates the cached values of the camera
  13107. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13108. */ updateCache(ignoreParentClass?: boolean): void;
  13109. /**
  13110. * @hidden
  13111. * Get current device position in babylon world
  13112. */ computeDevicePosition(): void;
  13113. /**
  13114. * Updates the current device position and rotation in the babylon world
  13115. */
  13116. update(): void;
  13117. /**
  13118. * @hidden
  13119. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13120. * @returns an identity matrix
  13121. */ getViewMatrix(): Matrix;
  13122. private _tmpMatrix;
  13123. /**
  13124. * This function is called by the two RIG cameras.
  13125. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13126. * @hidden
  13127. */ getWebVRViewMatrix(): Matrix;
  13128. /** @hidden */ getWebVRProjectionMatrix(): Matrix;
  13129. private _onGamepadConnectedObserver;
  13130. private _onGamepadDisconnectedObserver;
  13131. private _updateCacheWhenTrackingDisabledObserver;
  13132. /**
  13133. * Initializes the controllers and their meshes
  13134. */
  13135. initControllers(): void;
  13136. }
  13137. }
  13138. declare module BABYLON {
  13139. /**
  13140. * Size options for a post process
  13141. */
  13142. export type PostProcessOptions = {
  13143. width: number;
  13144. height: number;
  13145. };
  13146. /**
  13147. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13148. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13149. */
  13150. export class PostProcess {
  13151. /** Name of the PostProcess. */
  13152. name: string;
  13153. /**
  13154. * Gets or sets the unique id of the post process
  13155. */
  13156. uniqueId: number;
  13157. /**
  13158. * Width of the texture to apply the post process on
  13159. */
  13160. width: number;
  13161. /**
  13162. * Height of the texture to apply the post process on
  13163. */
  13164. height: number;
  13165. /**
  13166. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13167. * @hidden
  13168. */ outputTexture: Nullable<InternalTexture>;
  13169. /**
  13170. * Sampling mode used by the shader
  13171. * See https://doc.babylonjs.com/classes/3.1/texture
  13172. */
  13173. renderTargetSamplingMode: number;
  13174. /**
  13175. * Clear color to use when screen clearing
  13176. */
  13177. clearColor: Color4;
  13178. /**
  13179. * If the buffer needs to be cleared before applying the post process. (default: true)
  13180. * Should be set to false if shader will overwrite all previous pixels.
  13181. */
  13182. autoClear: boolean;
  13183. /**
  13184. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13185. */
  13186. alphaMode: number;
  13187. /**
  13188. * Sets the setAlphaBlendConstants of the babylon engine
  13189. */
  13190. alphaConstants: Color4;
  13191. /**
  13192. * Animations to be used for the post processing
  13193. */
  13194. animations: Animation[];
  13195. /**
  13196. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13197. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13198. */
  13199. enablePixelPerfectMode: boolean;
  13200. /**
  13201. * Force the postprocess to be applied without taking in account viewport
  13202. */
  13203. forceFullscreenViewport: boolean;
  13204. /**
  13205. * List of inspectable custom properties (used by the Inspector)
  13206. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13207. */
  13208. inspectableCustomProperties: IInspectable[];
  13209. /**
  13210. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13211. *
  13212. * | Value | Type | Description |
  13213. * | ----- | ----------------------------------- | ----------- |
  13214. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13215. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13216. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13217. *
  13218. */
  13219. scaleMode: number;
  13220. /**
  13221. * Force textures to be a power of two (default: false)
  13222. */
  13223. alwaysForcePOT: boolean;
  13224. private _samples;
  13225. /**
  13226. * Number of sample textures (default: 1)
  13227. */
  13228. samples: number;
  13229. /**
  13230. * Modify the scale of the post process to be the same as the viewport (default: false)
  13231. */
  13232. adaptScaleToCurrentViewport: boolean;
  13233. private _camera;
  13234. private _scene;
  13235. private _engine;
  13236. private _options;
  13237. private _reusable;
  13238. private _textureType;
  13239. /**
  13240. * Smart array of input and output textures for the post process.
  13241. * @hidden
  13242. */ textures: SmartArray<InternalTexture>;
  13243. /**
  13244. * The index in _textures that corresponds to the output texture.
  13245. * @hidden
  13246. */ currentRenderTextureInd: number;
  13247. private _effect;
  13248. private _samplers;
  13249. private _fragmentUrl;
  13250. private _vertexUrl;
  13251. private _parameters;
  13252. private _scaleRatio;
  13253. protected _indexParameters: any;
  13254. private _shareOutputWithPostProcess;
  13255. private _texelSize;
  13256. private _forcedOutputTexture;
  13257. /**
  13258. * Returns the fragment url or shader name used in the post process.
  13259. * @returns the fragment url or name in the shader store.
  13260. */
  13261. getEffectName(): string;
  13262. /**
  13263. * An event triggered when the postprocess is activated.
  13264. */
  13265. onActivateObservable: Observable<Camera>;
  13266. private _onActivateObserver;
  13267. /**
  13268. * A function that is added to the onActivateObservable
  13269. */
  13270. onActivate: Nullable<(camera: Camera) => void>;
  13271. /**
  13272. * An event triggered when the postprocess changes its size.
  13273. */
  13274. onSizeChangedObservable: Observable<PostProcess>;
  13275. private _onSizeChangedObserver;
  13276. /**
  13277. * A function that is added to the onSizeChangedObservable
  13278. */
  13279. onSizeChanged: (postProcess: PostProcess) => void;
  13280. /**
  13281. * An event triggered when the postprocess applies its effect.
  13282. */
  13283. onApplyObservable: Observable<Effect>;
  13284. private _onApplyObserver;
  13285. /**
  13286. * A function that is added to the onApplyObservable
  13287. */
  13288. onApply: (effect: Effect) => void;
  13289. /**
  13290. * An event triggered before rendering the postprocess
  13291. */
  13292. onBeforeRenderObservable: Observable<Effect>;
  13293. private _onBeforeRenderObserver;
  13294. /**
  13295. * A function that is added to the onBeforeRenderObservable
  13296. */
  13297. onBeforeRender: (effect: Effect) => void;
  13298. /**
  13299. * An event triggered after rendering the postprocess
  13300. */
  13301. onAfterRenderObservable: Observable<Effect>;
  13302. private _onAfterRenderObserver;
  13303. /**
  13304. * A function that is added to the onAfterRenderObservable
  13305. */
  13306. onAfterRender: (efect: Effect) => void;
  13307. /**
  13308. * 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
  13309. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13310. */
  13311. inputTexture: InternalTexture;
  13312. /**
  13313. * Gets the camera which post process is applied to.
  13314. * @returns The camera the post process is applied to.
  13315. */
  13316. getCamera(): Camera;
  13317. /**
  13318. * Gets the texel size of the postprocess.
  13319. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13320. */
  13321. readonly texelSize: Vector2;
  13322. /**
  13323. * Creates a new instance PostProcess
  13324. * @param name The name of the PostProcess.
  13325. * @param fragmentUrl The url of the fragment shader to be used.
  13326. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13327. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13328. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13329. * @param camera The camera to apply the render pass to.
  13330. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13331. * @param engine The engine which the post process will be applied. (default: current engine)
  13332. * @param reusable If the post process can be reused on the same frame. (default: false)
  13333. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13334. * @param textureType Type of textures used when performing the post process. (default: 0)
  13335. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13336. * @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
  13337. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13338. */
  13339. constructor(
  13340. /** Name of the PostProcess. */
  13341. 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);
  13342. /**
  13343. * Gets a string idenfifying the name of the class
  13344. * @returns "PostProcess" string
  13345. */
  13346. getClassName(): string;
  13347. /**
  13348. * Gets the engine which this post process belongs to.
  13349. * @returns The engine the post process was enabled with.
  13350. */
  13351. getEngine(): Engine;
  13352. /**
  13353. * The effect that is created when initializing the post process.
  13354. * @returns The created effect corrisponding the the postprocess.
  13355. */
  13356. getEffect(): Effect;
  13357. /**
  13358. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13359. * @param postProcess The post process to share the output with.
  13360. * @returns This post process.
  13361. */
  13362. shareOutputWith(postProcess: PostProcess): PostProcess;
  13363. /**
  13364. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13365. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13366. */
  13367. useOwnOutput(): void;
  13368. /**
  13369. * Updates the effect with the current post process compile time values and recompiles the shader.
  13370. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13371. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13372. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13373. * @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
  13374. * @param onCompiled Called when the shader has been compiled.
  13375. * @param onError Called if there is an error when compiling a shader.
  13376. */
  13377. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13378. /**
  13379. * The post process is reusable if it can be used multiple times within one frame.
  13380. * @returns If the post process is reusable
  13381. */
  13382. isReusable(): boolean;
  13383. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13384. markTextureDirty(): void;
  13385. /**
  13386. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13387. * 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.
  13388. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13389. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13390. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13391. * @returns The target texture that was bound to be written to.
  13392. */
  13393. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13394. /**
  13395. * If the post process is supported.
  13396. */
  13397. readonly isSupported: boolean;
  13398. /**
  13399. * The aspect ratio of the output texture.
  13400. */
  13401. readonly aspectRatio: number;
  13402. /**
  13403. * Get a value indicating if the post-process is ready to be used
  13404. * @returns true if the post-process is ready (shader is compiled)
  13405. */
  13406. isReady(): boolean;
  13407. /**
  13408. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13409. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13410. */
  13411. apply(): Nullable<Effect>;
  13412. private _disposeTextures;
  13413. /**
  13414. * Disposes the post process.
  13415. * @param camera The camera to dispose the post process on.
  13416. */
  13417. dispose(camera?: Camera): void;
  13418. }
  13419. }
  13420. declare module BABYLON {
  13421. /**
  13422. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13423. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13424. */
  13425. export class PostProcessManager {
  13426. private _scene;
  13427. private _indexBuffer;
  13428. private _vertexBuffers;
  13429. /**
  13430. * Creates a new instance PostProcess
  13431. * @param scene The scene that the post process is associated with.
  13432. */
  13433. constructor(scene: Scene);
  13434. private _prepareBuffers;
  13435. private _buildIndexBuffer;
  13436. /**
  13437. * Rebuilds the vertex buffers of the manager.
  13438. * @hidden
  13439. */ rebuild(): void;
  13440. /**
  13441. * Prepares a frame to be run through a post process.
  13442. * @param sourceTexture The input texture to the post procesess. (default: null)
  13443. * @param postProcesses An array of post processes to be run. (default: null)
  13444. * @returns True if the post processes were able to be run.
  13445. * @hidden
  13446. */ prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13447. /**
  13448. * Manually render a set of post processes to a texture.
  13449. * @param postProcesses An array of post processes to be run.
  13450. * @param targetTexture The target texture to render to.
  13451. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13452. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13453. * @param lodLevel defines which lod of the texture to render to
  13454. */
  13455. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13456. /**
  13457. * Finalize the result of the output of the postprocesses.
  13458. * @param doNotPresent If true the result will not be displayed to the screen.
  13459. * @param targetTexture The target texture to render to.
  13460. * @param faceIndex The index of the face to bind the target texture to.
  13461. * @param postProcesses The array of post processes to render.
  13462. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13463. * @hidden
  13464. */ finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13465. /**
  13466. * Disposes of the post process manager.
  13467. */
  13468. dispose(): void;
  13469. }
  13470. }
  13471. declare module BABYLON {
  13472. interface AbstractScene {
  13473. /**
  13474. * The list of layers (background and foreground) of the scene
  13475. */
  13476. layers: Array<Layer>;
  13477. }
  13478. /**
  13479. * Defines the layer scene component responsible to manage any layers
  13480. * in a given scene.
  13481. */
  13482. export class LayerSceneComponent implements ISceneComponent {
  13483. /**
  13484. * The component name helpfull to identify the component in the list of scene components.
  13485. */
  13486. readonly name: string;
  13487. /**
  13488. * The scene the component belongs to.
  13489. */
  13490. scene: Scene;
  13491. private _engine;
  13492. /**
  13493. * Creates a new instance of the component for the given scene
  13494. * @param scene Defines the scene to register the component in
  13495. */
  13496. constructor(scene: Scene);
  13497. /**
  13498. * Registers the component in a given scene
  13499. */
  13500. register(): void;
  13501. /**
  13502. * Rebuilds the elements related to this component in case of
  13503. * context lost for instance.
  13504. */
  13505. rebuild(): void;
  13506. /**
  13507. * Disposes the component and the associated ressources.
  13508. */
  13509. dispose(): void;
  13510. private _draw;
  13511. private _drawCameraPredicate;
  13512. private _drawCameraBackground;
  13513. private _drawCameraForeground;
  13514. private _drawRenderTargetPredicate;
  13515. private _drawRenderTargetBackground;
  13516. private _drawRenderTargetForeground;
  13517. }
  13518. }
  13519. declare module BABYLON {
  13520. /** @hidden */
  13521. export var layerPixelShader: {
  13522. name: string;
  13523. shader: string;
  13524. };
  13525. }
  13526. declare module BABYLON {
  13527. /** @hidden */
  13528. export var layerVertexShader: {
  13529. name: string;
  13530. shader: string;
  13531. };
  13532. }
  13533. declare module BABYLON {
  13534. /**
  13535. * This represents a full screen 2d layer.
  13536. * This can be useful to display a picture in the background of your scene for instance.
  13537. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13538. */
  13539. export class Layer {
  13540. /**
  13541. * Define the name of the layer.
  13542. */
  13543. name: string;
  13544. /**
  13545. * Define the texture the layer should display.
  13546. */
  13547. texture: Nullable<Texture>;
  13548. /**
  13549. * Is the layer in background or foreground.
  13550. */
  13551. isBackground: boolean;
  13552. /**
  13553. * Define the color of the layer (instead of texture).
  13554. */
  13555. color: Color4;
  13556. /**
  13557. * Define the scale of the layer in order to zoom in out of the texture.
  13558. */
  13559. scale: Vector2;
  13560. /**
  13561. * Define an offset for the layer in order to shift the texture.
  13562. */
  13563. offset: Vector2;
  13564. /**
  13565. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13566. */
  13567. alphaBlendingMode: number;
  13568. /**
  13569. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13570. * Alpha test will not mix with the background color in case of transparency.
  13571. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13572. */
  13573. alphaTest: boolean;
  13574. /**
  13575. * Define a mask to restrict the layer to only some of the scene cameras.
  13576. */
  13577. layerMask: number;
  13578. /**
  13579. * Define the list of render target the layer is visible into.
  13580. */
  13581. renderTargetTextures: RenderTargetTexture[];
  13582. /**
  13583. * Define if the layer is only used in renderTarget or if it also
  13584. * renders in the main frame buffer of the canvas.
  13585. */
  13586. renderOnlyInRenderTargetTextures: boolean;
  13587. private _scene;
  13588. private _vertexBuffers;
  13589. private _indexBuffer;
  13590. private _effect;
  13591. private _alphaTestEffect;
  13592. /**
  13593. * An event triggered when the layer is disposed.
  13594. */
  13595. onDisposeObservable: Observable<Layer>;
  13596. private _onDisposeObserver;
  13597. /**
  13598. * Back compatibility with callback before the onDisposeObservable existed.
  13599. * The set callback will be triggered when the layer has been disposed.
  13600. */
  13601. onDispose: () => void;
  13602. /**
  13603. * An event triggered before rendering the scene
  13604. */
  13605. onBeforeRenderObservable: Observable<Layer>;
  13606. private _onBeforeRenderObserver;
  13607. /**
  13608. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13609. * The set callback will be triggered just before rendering the layer.
  13610. */
  13611. onBeforeRender: () => void;
  13612. /**
  13613. * An event triggered after rendering the scene
  13614. */
  13615. onAfterRenderObservable: Observable<Layer>;
  13616. private _onAfterRenderObserver;
  13617. /**
  13618. * Back compatibility with callback before the onAfterRenderObservable existed.
  13619. * The set callback will be triggered just after rendering the layer.
  13620. */
  13621. onAfterRender: () => void;
  13622. /**
  13623. * Instantiates a new layer.
  13624. * This represents a full screen 2d layer.
  13625. * This can be useful to display a picture in the background of your scene for instance.
  13626. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13627. * @param name Define the name of the layer in the scene
  13628. * @param imgUrl Define the url of the texture to display in the layer
  13629. * @param scene Define the scene the layer belongs to
  13630. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13631. * @param color Defines a color for the layer
  13632. */
  13633. constructor(
  13634. /**
  13635. * Define the name of the layer.
  13636. */
  13637. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13638. private _createIndexBuffer;
  13639. /** @hidden */ rebuild(): void;
  13640. /**
  13641. * Renders the layer in the scene.
  13642. */
  13643. render(): void;
  13644. /**
  13645. * Disposes and releases the associated ressources.
  13646. */
  13647. dispose(): void;
  13648. }
  13649. }
  13650. declare module BABYLON {
  13651. interface AbstractScene {
  13652. /**
  13653. * The list of procedural textures added to the scene
  13654. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13655. */
  13656. proceduralTextures: Array<ProceduralTexture>;
  13657. }
  13658. /**
  13659. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13660. * in a given scene.
  13661. */
  13662. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13663. /**
  13664. * The component name helpfull to identify the component in the list of scene components.
  13665. */
  13666. readonly name: string;
  13667. /**
  13668. * The scene the component belongs to.
  13669. */
  13670. scene: Scene;
  13671. /**
  13672. * Creates a new instance of the component for the given scene
  13673. * @param scene Defines the scene to register the component in
  13674. */
  13675. constructor(scene: Scene);
  13676. /**
  13677. * Registers the component in a given scene
  13678. */
  13679. register(): void;
  13680. /**
  13681. * Rebuilds the elements related to this component in case of
  13682. * context lost for instance.
  13683. */
  13684. rebuild(): void;
  13685. /**
  13686. * Disposes the component and the associated ressources.
  13687. */
  13688. dispose(): void;
  13689. private _beforeClear;
  13690. }
  13691. }
  13692. declare module BABYLON {
  13693. /** @hidden */
  13694. export var proceduralVertexShader: {
  13695. name: string;
  13696. shader: string;
  13697. };
  13698. }
  13699. declare module BABYLON {
  13700. /**
  13701. * 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.
  13702. * This is the base class of any Procedural texture and contains most of the shareable code.
  13703. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13704. */
  13705. export class ProceduralTexture extends Texture {
  13706. isCube: boolean;
  13707. /**
  13708. * Define if the texture is enabled or not (disabled texture will not render)
  13709. */
  13710. isEnabled: boolean;
  13711. /**
  13712. * Define if the texture must be cleared before rendering (default is true)
  13713. */
  13714. autoClear: boolean;
  13715. /**
  13716. * Callback called when the texture is generated
  13717. */
  13718. onGenerated: () => void;
  13719. /**
  13720. * Event raised when the texture is generated
  13721. */
  13722. onGeneratedObservable: Observable<ProceduralTexture>;
  13723. /** @hidden */ generateMipMaps: boolean;
  13724. /** @hidden **/ effect: Effect;
  13725. /** @hidden */ textures: {
  13726. [key: string]: Texture;
  13727. };
  13728. private _size;
  13729. private _currentRefreshId;
  13730. private _refreshRate;
  13731. private _vertexBuffers;
  13732. private _indexBuffer;
  13733. private _uniforms;
  13734. private _samplers;
  13735. private _fragment;
  13736. private _floats;
  13737. private _ints;
  13738. private _floatsArrays;
  13739. private _colors3;
  13740. private _colors4;
  13741. private _vectors2;
  13742. private _vectors3;
  13743. private _matrices;
  13744. private _fallbackTexture;
  13745. private _fallbackTextureUsed;
  13746. private _engine;
  13747. private _cachedDefines;
  13748. private _contentUpdateId;
  13749. private _contentData;
  13750. /**
  13751. * Instantiates a new procedural texture.
  13752. * 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.
  13753. * This is the base class of any Procedural texture and contains most of the shareable code.
  13754. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13755. * @param name Define the name of the texture
  13756. * @param size Define the size of the texture to create
  13757. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13758. * @param scene Define the scene the texture belongs to
  13759. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13760. * @param generateMipMaps Define if the texture should creates mip maps or not
  13761. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13762. */
  13763. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13764. /**
  13765. * The effect that is created when initializing the post process.
  13766. * @returns The created effect corrisponding the the postprocess.
  13767. */
  13768. getEffect(): Effect;
  13769. /**
  13770. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13771. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13772. */
  13773. getContent(): Nullable<ArrayBufferView>;
  13774. private _createIndexBuffer;
  13775. /** @hidden */ rebuild(): void;
  13776. /**
  13777. * Resets the texture in order to recreate its associated resources.
  13778. * This can be called in case of context loss
  13779. */
  13780. reset(): void;
  13781. protected _getDefines(): string;
  13782. /**
  13783. * Is the texture ready to be used ? (rendered at least once)
  13784. * @returns true if ready, otherwise, false.
  13785. */
  13786. isReady(): boolean;
  13787. /**
  13788. * Resets the refresh counter of the texture and start bak from scratch.
  13789. * Could be useful to regenerate the texture if it is setup to render only once.
  13790. */
  13791. resetRefreshCounter(): void;
  13792. /**
  13793. * Set the fragment shader to use in order to render the texture.
  13794. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13795. */
  13796. setFragment(fragment: any): void;
  13797. /**
  13798. * Define the refresh rate of the texture or the rendering frequency.
  13799. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13800. */
  13801. refreshRate: number;
  13802. /** @hidden */ shouldRender(): boolean;
  13803. /**
  13804. * Get the size the texture is rendering at.
  13805. * @returns the size (texture is always squared)
  13806. */
  13807. getRenderSize(): number;
  13808. /**
  13809. * Resize the texture to new value.
  13810. * @param size Define the new size the texture should have
  13811. * @param generateMipMaps Define whether the new texture should create mip maps
  13812. */
  13813. resize(size: number, generateMipMaps: boolean): void;
  13814. private _checkUniform;
  13815. /**
  13816. * Set a texture in the shader program used to render.
  13817. * @param name Define the name of the uniform samplers as defined in the shader
  13818. * @param texture Define the texture to bind to this sampler
  13819. * @return the texture itself allowing "fluent" like uniform updates
  13820. */
  13821. setTexture(name: string, texture: Texture): ProceduralTexture;
  13822. /**
  13823. * Set a float in the shader.
  13824. * @param name Define the name of the uniform as defined in the shader
  13825. * @param value Define the value to give to the uniform
  13826. * @return the texture itself allowing "fluent" like uniform updates
  13827. */
  13828. setFloat(name: string, value: number): ProceduralTexture;
  13829. /**
  13830. * Set a int in the shader.
  13831. * @param name Define the name of the uniform as defined in the shader
  13832. * @param value Define the value to give to the uniform
  13833. * @return the texture itself allowing "fluent" like uniform updates
  13834. */
  13835. setInt(name: string, value: number): ProceduralTexture;
  13836. /**
  13837. * Set an array of floats in the shader.
  13838. * @param name Define the name of the uniform as defined in the shader
  13839. * @param value Define the value to give to the uniform
  13840. * @return the texture itself allowing "fluent" like uniform updates
  13841. */
  13842. setFloats(name: string, value: number[]): ProceduralTexture;
  13843. /**
  13844. * Set a vec3 in the shader from a Color3.
  13845. * @param name Define the name of the uniform as defined in the shader
  13846. * @param value Define the value to give to the uniform
  13847. * @return the texture itself allowing "fluent" like uniform updates
  13848. */
  13849. setColor3(name: string, value: Color3): ProceduralTexture;
  13850. /**
  13851. * Set a vec4 in the shader from a Color4.
  13852. * @param name Define the name of the uniform as defined in the shader
  13853. * @param value Define the value to give to the uniform
  13854. * @return the texture itself allowing "fluent" like uniform updates
  13855. */
  13856. setColor4(name: string, value: Color4): ProceduralTexture;
  13857. /**
  13858. * Set a vec2 in the shader from a Vector2.
  13859. * @param name Define the name of the uniform as defined in the shader
  13860. * @param value Define the value to give to the uniform
  13861. * @return the texture itself allowing "fluent" like uniform updates
  13862. */
  13863. setVector2(name: string, value: Vector2): ProceduralTexture;
  13864. /**
  13865. * Set a vec3 in the shader from a Vector3.
  13866. * @param name Define the name of the uniform as defined in the shader
  13867. * @param value Define the value to give to the uniform
  13868. * @return the texture itself allowing "fluent" like uniform updates
  13869. */
  13870. setVector3(name: string, value: Vector3): ProceduralTexture;
  13871. /**
  13872. * Set a mat4 in the shader from a MAtrix.
  13873. * @param name Define the name of the uniform as defined in the shader
  13874. * @param value Define the value to give to the uniform
  13875. * @return the texture itself allowing "fluent" like uniform updates
  13876. */
  13877. setMatrix(name: string, value: Matrix): ProceduralTexture;
  13878. /**
  13879. * Render the texture to its associated render target.
  13880. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  13881. */
  13882. render(useCameraPostProcess?: boolean): void;
  13883. /**
  13884. * Clone the texture.
  13885. * @returns the cloned texture
  13886. */
  13887. clone(): ProceduralTexture;
  13888. /**
  13889. * Dispose the texture and release its asoociated resources.
  13890. */
  13891. dispose(): void;
  13892. }
  13893. }
  13894. declare module BABYLON {
  13895. /**
  13896. * This represents the base class for particle system in Babylon.
  13897. * 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.
  13898. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  13899. * @example https://doc.babylonjs.com/babylon101/particles
  13900. */
  13901. export class BaseParticleSystem {
  13902. /**
  13903. * Source color is added to the destination color without alpha affecting the result
  13904. */
  13905. static BLENDMODE_ONEONE: number;
  13906. /**
  13907. * Blend current color and particle color using particle’s alpha
  13908. */
  13909. static BLENDMODE_STANDARD: number;
  13910. /**
  13911. * Add current color and particle color multiplied by particle’s alpha
  13912. */
  13913. static BLENDMODE_ADD: number;
  13914. /**
  13915. * Multiply current color with particle color
  13916. */
  13917. static BLENDMODE_MULTIPLY: number;
  13918. /**
  13919. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  13920. */
  13921. static BLENDMODE_MULTIPLYADD: number;
  13922. /**
  13923. * List of animations used by the particle system.
  13924. */
  13925. animations: Animation[];
  13926. /**
  13927. * The id of the Particle system.
  13928. */
  13929. id: string;
  13930. /**
  13931. * The friendly name of the Particle system.
  13932. */
  13933. name: string;
  13934. /**
  13935. * The rendering group used by the Particle system to chose when to render.
  13936. */
  13937. renderingGroupId: number;
  13938. /**
  13939. * The emitter represents the Mesh or position we are attaching the particle system to.
  13940. */
  13941. emitter: Nullable<AbstractMesh | Vector3>;
  13942. /**
  13943. * The maximum number of particles to emit per frame
  13944. */
  13945. emitRate: number;
  13946. /**
  13947. * If you want to launch only a few particles at once, that can be done, as well.
  13948. */
  13949. manualEmitCount: number;
  13950. /**
  13951. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13952. */
  13953. updateSpeed: number;
  13954. /**
  13955. * The amount of time the particle system is running (depends of the overall update speed).
  13956. */
  13957. targetStopDuration: number;
  13958. /**
  13959. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13960. */
  13961. disposeOnStop: boolean;
  13962. /**
  13963. * Minimum power of emitting particles.
  13964. */
  13965. minEmitPower: number;
  13966. /**
  13967. * Maximum power of emitting particles.
  13968. */
  13969. maxEmitPower: number;
  13970. /**
  13971. * Minimum life time of emitting particles.
  13972. */
  13973. minLifeTime: number;
  13974. /**
  13975. * Maximum life time of emitting particles.
  13976. */
  13977. maxLifeTime: number;
  13978. /**
  13979. * Minimum Size of emitting particles.
  13980. */
  13981. minSize: number;
  13982. /**
  13983. * Maximum Size of emitting particles.
  13984. */
  13985. maxSize: number;
  13986. /**
  13987. * Minimum scale of emitting particles on X axis.
  13988. */
  13989. minScaleX: number;
  13990. /**
  13991. * Maximum scale of emitting particles on X axis.
  13992. */
  13993. maxScaleX: number;
  13994. /**
  13995. * Minimum scale of emitting particles on Y axis.
  13996. */
  13997. minScaleY: number;
  13998. /**
  13999. * Maximum scale of emitting particles on Y axis.
  14000. */
  14001. maxScaleY: number;
  14002. /**
  14003. * Gets or sets the minimal initial rotation in radians.
  14004. */
  14005. minInitialRotation: number;
  14006. /**
  14007. * Gets or sets the maximal initial rotation in radians.
  14008. */
  14009. maxInitialRotation: number;
  14010. /**
  14011. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14012. */
  14013. minAngularSpeed: number;
  14014. /**
  14015. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14016. */
  14017. maxAngularSpeed: number;
  14018. /**
  14019. * The texture used to render each particle. (this can be a spritesheet)
  14020. */
  14021. particleTexture: Nullable<Texture>;
  14022. /**
  14023. * The layer mask we are rendering the particles through.
  14024. */
  14025. layerMask: number;
  14026. /**
  14027. * This can help using your own shader to render the particle system.
  14028. * The according effect will be created
  14029. */
  14030. customShader: any;
  14031. /**
  14032. * By default particle system starts as soon as they are created. This prevents the
  14033. * automatic start to happen and let you decide when to start emitting particles.
  14034. */
  14035. preventAutoStart: boolean;
  14036. private _noiseTexture;
  14037. /**
  14038. * Gets or sets a texture used to add random noise to particle positions
  14039. */
  14040. noiseTexture: Nullable<ProceduralTexture>;
  14041. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14042. noiseStrength: Vector3;
  14043. /**
  14044. * Callback triggered when the particle animation is ending.
  14045. */
  14046. onAnimationEnd: Nullable<() => void>;
  14047. /**
  14048. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14049. */
  14050. blendMode: number;
  14051. /**
  14052. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14053. * to override the particles.
  14054. */
  14055. forceDepthWrite: boolean;
  14056. /** 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 */
  14057. preWarmCycles: number;
  14058. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14059. preWarmStepOffset: number;
  14060. /**
  14061. * 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)
  14062. */
  14063. spriteCellChangeSpeed: number;
  14064. /**
  14065. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14066. */
  14067. startSpriteCellID: number;
  14068. /**
  14069. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14070. */
  14071. endSpriteCellID: number;
  14072. /**
  14073. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14074. */
  14075. spriteCellWidth: number;
  14076. /**
  14077. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14078. */
  14079. spriteCellHeight: number;
  14080. /**
  14081. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14082. */
  14083. spriteRandomStartCell: boolean;
  14084. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14085. translationPivot: Vector2;
  14086. /** @hidden */
  14087. protected _isAnimationSheetEnabled: boolean;
  14088. /**
  14089. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14090. */
  14091. beginAnimationOnStart: boolean;
  14092. /**
  14093. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14094. */
  14095. beginAnimationFrom: number;
  14096. /**
  14097. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14098. */
  14099. beginAnimationTo: number;
  14100. /**
  14101. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14102. */
  14103. beginAnimationLoop: boolean;
  14104. /**
  14105. * Gets or sets a world offset applied to all particles
  14106. */
  14107. worldOffset: Vector3;
  14108. /**
  14109. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14110. */
  14111. isAnimationSheetEnabled: boolean;
  14112. /**
  14113. * Get hosting scene
  14114. * @returns the scene
  14115. */
  14116. getScene(): Scene;
  14117. /**
  14118. * You can use gravity if you want to give an orientation to your particles.
  14119. */
  14120. gravity: Vector3;
  14121. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14122. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14123. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14124. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14125. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14126. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14127. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14128. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14129. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14130. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14131. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14132. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14133. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14134. /**
  14135. * Defines the delay in milliseconds before starting the system (0 by default)
  14136. */
  14137. startDelay: number;
  14138. /**
  14139. * Gets the current list of drag gradients.
  14140. * You must use addDragGradient and removeDragGradient to udpate this list
  14141. * @returns the list of drag gradients
  14142. */
  14143. getDragGradients(): Nullable<Array<FactorGradient>>;
  14144. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14145. limitVelocityDamping: number;
  14146. /**
  14147. * Gets the current list of limit velocity gradients.
  14148. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14149. * @returns the list of limit velocity gradients
  14150. */
  14151. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14152. /**
  14153. * Gets the current list of color gradients.
  14154. * You must use addColorGradient and removeColorGradient to udpate this list
  14155. * @returns the list of color gradients
  14156. */
  14157. getColorGradients(): Nullable<Array<ColorGradient>>;
  14158. /**
  14159. * Gets the current list of size gradients.
  14160. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14161. * @returns the list of size gradients
  14162. */
  14163. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14164. /**
  14165. * Gets the current list of color remap gradients.
  14166. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14167. * @returns the list of color remap gradients
  14168. */
  14169. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14170. /**
  14171. * Gets the current list of alpha remap gradients.
  14172. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14173. * @returns the list of alpha remap gradients
  14174. */
  14175. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14176. /**
  14177. * Gets the current list of life time gradients.
  14178. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14179. * @returns the list of life time gradients
  14180. */
  14181. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14182. /**
  14183. * Gets the current list of angular speed gradients.
  14184. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14185. * @returns the list of angular speed gradients
  14186. */
  14187. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14188. /**
  14189. * Gets the current list of velocity gradients.
  14190. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14191. * @returns the list of velocity gradients
  14192. */
  14193. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14194. /**
  14195. * Gets the current list of start size gradients.
  14196. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14197. * @returns the list of start size gradients
  14198. */
  14199. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14200. /**
  14201. * Gets the current list of emit rate gradients.
  14202. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14203. * @returns the list of emit rate gradients
  14204. */
  14205. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14206. /**
  14207. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14208. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14209. */
  14210. direction1: Vector3;
  14211. /**
  14212. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14213. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14214. */
  14215. direction2: Vector3;
  14216. /**
  14217. * 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.
  14218. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14219. */
  14220. minEmitBox: Vector3;
  14221. /**
  14222. * 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.
  14223. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14224. */
  14225. maxEmitBox: Vector3;
  14226. /**
  14227. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14228. */
  14229. color1: Color4;
  14230. /**
  14231. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14232. */
  14233. color2: Color4;
  14234. /**
  14235. * Color the particle will have at the end of its lifetime
  14236. */
  14237. colorDead: Color4;
  14238. /**
  14239. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14240. */
  14241. textureMask: Color4;
  14242. /**
  14243. * The particle emitter type defines the emitter used by the particle system.
  14244. * It can be for example box, sphere, or cone...
  14245. */
  14246. particleEmitterType: IParticleEmitterType;
  14247. /** @hidden */ isSubEmitter: boolean;
  14248. /**
  14249. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14250. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14251. */
  14252. billboardMode: number;
  14253. protected _isBillboardBased: boolean;
  14254. /**
  14255. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14256. */
  14257. isBillboardBased: boolean;
  14258. /**
  14259. * The scene the particle system belongs to.
  14260. */
  14261. protected _scene: Scene;
  14262. /**
  14263. * Local cache of defines for image processing.
  14264. */
  14265. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14266. /**
  14267. * Default configuration related to image processing available in the standard Material.
  14268. */
  14269. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14270. /**
  14271. * Gets the image processing configuration used either in this material.
  14272. */
  14273. /**
  14274. * Sets the Default image processing configuration used either in the this material.
  14275. *
  14276. * If sets to null, the scene one is in use.
  14277. */
  14278. imageProcessingConfiguration: ImageProcessingConfiguration;
  14279. /**
  14280. * Attaches a new image processing configuration to the Standard Material.
  14281. * @param configuration
  14282. */
  14283. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14284. /** @hidden */
  14285. protected _reset(): void;
  14286. /** @hidden */
  14287. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14288. /**
  14289. * Instantiates a particle system.
  14290. * 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.
  14291. * @param name The name of the particle system
  14292. */
  14293. constructor(name: string);
  14294. /**
  14295. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14296. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14297. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14298. * @returns the emitter
  14299. */
  14300. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14301. /**
  14302. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14303. * @param radius The radius of the hemisphere to emit from
  14304. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14305. * @returns the emitter
  14306. */
  14307. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14308. /**
  14309. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14310. * @param radius The radius of the sphere to emit from
  14311. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14312. * @returns the emitter
  14313. */
  14314. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14315. /**
  14316. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14317. * @param radius The radius of the sphere to emit from
  14318. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14319. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14320. * @returns the emitter
  14321. */
  14322. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14323. /**
  14324. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14325. * @param radius The radius of the emission cylinder
  14326. * @param height The height of the emission cylinder
  14327. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14328. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14329. * @returns the emitter
  14330. */
  14331. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14332. /**
  14333. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14334. * @param radius The radius of the cylinder to emit from
  14335. * @param height The height of the emission cylinder
  14336. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14337. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14338. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14339. * @returns the emitter
  14340. */
  14341. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14342. /**
  14343. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14344. * @param radius The radius of the cone to emit from
  14345. * @param angle The base angle of the cone
  14346. * @returns the emitter
  14347. */
  14348. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14349. /**
  14350. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14351. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14352. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14353. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14354. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14355. * @returns the emitter
  14356. */
  14357. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14358. }
  14359. }
  14360. declare module BABYLON {
  14361. /**
  14362. * Type of sub emitter
  14363. */
  14364. export enum SubEmitterType {
  14365. /**
  14366. * Attached to the particle over it's lifetime
  14367. */
  14368. ATTACHED = 0,
  14369. /**
  14370. * Created when the particle dies
  14371. */
  14372. END = 1
  14373. }
  14374. /**
  14375. * Sub emitter class used to emit particles from an existing particle
  14376. */
  14377. export class SubEmitter {
  14378. /**
  14379. * the particle system to be used by the sub emitter
  14380. */
  14381. particleSystem: ParticleSystem;
  14382. /**
  14383. * Type of the submitter (Default: END)
  14384. */
  14385. type: SubEmitterType;
  14386. /**
  14387. * 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)
  14388. * Note: This only is supported when using an emitter of type Mesh
  14389. */
  14390. inheritDirection: boolean;
  14391. /**
  14392. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14393. */
  14394. inheritedVelocityAmount: number;
  14395. /**
  14396. * Creates a sub emitter
  14397. * @param particleSystem the particle system to be used by the sub emitter
  14398. */
  14399. constructor(
  14400. /**
  14401. * the particle system to be used by the sub emitter
  14402. */
  14403. particleSystem: ParticleSystem);
  14404. /**
  14405. * Clones the sub emitter
  14406. * @returns the cloned sub emitter
  14407. */
  14408. clone(): SubEmitter;
  14409. /**
  14410. * Serialize current object to a JSON object
  14411. * @returns the serialized object
  14412. */
  14413. serialize(): any;
  14414. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14415. /**
  14416. * Creates a new SubEmitter from a serialized JSON version
  14417. * @param serializationObject defines the JSON object to read from
  14418. * @param scene defines the hosting scene
  14419. * @param rootUrl defines the rootUrl for data loading
  14420. * @returns a new SubEmitter
  14421. */
  14422. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14423. /** Release associated resources */
  14424. dispose(): void;
  14425. }
  14426. }
  14427. declare module BABYLON {
  14428. /** @hidden */
  14429. export var clipPlaneFragmentDeclaration: {
  14430. name: string;
  14431. shader: string;
  14432. };
  14433. }
  14434. declare module BABYLON {
  14435. /** @hidden */
  14436. export var imageProcessingDeclaration: {
  14437. name: string;
  14438. shader: string;
  14439. };
  14440. }
  14441. declare module BABYLON {
  14442. /** @hidden */
  14443. export var imageProcessingFunctions: {
  14444. name: string;
  14445. shader: string;
  14446. };
  14447. }
  14448. declare module BABYLON {
  14449. /** @hidden */
  14450. export var clipPlaneFragment: {
  14451. name: string;
  14452. shader: string;
  14453. };
  14454. }
  14455. declare module BABYLON {
  14456. /** @hidden */
  14457. export var particlesPixelShader: {
  14458. name: string;
  14459. shader: string;
  14460. };
  14461. }
  14462. declare module BABYLON {
  14463. /** @hidden */
  14464. export var clipPlaneVertexDeclaration: {
  14465. name: string;
  14466. shader: string;
  14467. };
  14468. }
  14469. declare module BABYLON {
  14470. /** @hidden */
  14471. export var clipPlaneVertex: {
  14472. name: string;
  14473. shader: string;
  14474. };
  14475. }
  14476. declare module BABYLON {
  14477. /** @hidden */
  14478. export var particlesVertexShader: {
  14479. name: string;
  14480. shader: string;
  14481. };
  14482. }
  14483. declare module BABYLON {
  14484. /**
  14485. * This represents a particle system in Babylon.
  14486. * 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.
  14487. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14488. * @example https://doc.babylonjs.com/babylon101/particles
  14489. */
  14490. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14491. /**
  14492. * Billboard mode will only apply to Y axis
  14493. */
  14494. static readonly BILLBOARDMODE_Y: number;
  14495. /**
  14496. * Billboard mode will apply to all axes
  14497. */
  14498. static readonly BILLBOARDMODE_ALL: number;
  14499. /**
  14500. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14501. */
  14502. static readonly BILLBOARDMODE_STRETCHED: number;
  14503. /**
  14504. * This function can be defined to provide custom update for active particles.
  14505. * This function will be called instead of regular update (age, position, color, etc.).
  14506. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14507. */
  14508. updateFunction: (particles: Particle[]) => void;
  14509. private _emitterWorldMatrix;
  14510. /**
  14511. * This function can be defined to specify initial direction for every new particle.
  14512. * It by default use the emitterType defined function
  14513. */
  14514. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14515. /**
  14516. * This function can be defined to specify initial position for every new particle.
  14517. * It by default use the emitterType defined function
  14518. */
  14519. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14520. /**
  14521. * @hidden
  14522. */ inheritedVelocityOffset: Vector3;
  14523. /**
  14524. * An event triggered when the system is disposed
  14525. */
  14526. onDisposeObservable: Observable<ParticleSystem>;
  14527. private _onDisposeObserver;
  14528. /**
  14529. * Sets a callback that will be triggered when the system is disposed
  14530. */
  14531. onDispose: () => void;
  14532. private _particles;
  14533. private _epsilon;
  14534. private _capacity;
  14535. private _stockParticles;
  14536. private _newPartsExcess;
  14537. private _vertexData;
  14538. private _vertexBuffer;
  14539. private _vertexBuffers;
  14540. private _spriteBuffer;
  14541. private _indexBuffer;
  14542. private _effect;
  14543. private _customEffect;
  14544. private _cachedDefines;
  14545. private _scaledColorStep;
  14546. private _colorDiff;
  14547. private _scaledDirection;
  14548. private _scaledGravity;
  14549. private _currentRenderId;
  14550. private _alive;
  14551. private _useInstancing;
  14552. private _started;
  14553. private _stopped;
  14554. private _actualFrame;
  14555. private _scaledUpdateSpeed;
  14556. private _vertexBufferSize;
  14557. /** @hidden */ currentEmitRateGradient: Nullable<FactorGradient>;
  14558. /** @hidden */ currentEmitRate1: number;
  14559. /** @hidden */ currentEmitRate2: number;
  14560. /** @hidden */ currentStartSizeGradient: Nullable<FactorGradient>;
  14561. /** @hidden */ currentStartSize1: number;
  14562. /** @hidden */ currentStartSize2: number;
  14563. private readonly _rawTextureWidth;
  14564. private _rampGradientsTexture;
  14565. private _useRampGradients;
  14566. /** Gets or sets a boolean indicating that ramp gradients must be used
  14567. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14568. */
  14569. useRampGradients: boolean;
  14570. /**
  14571. * 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.
  14572. * 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: [])
  14573. */
  14574. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14575. private _subEmitters;
  14576. /**
  14577. * @hidden
  14578. * If the particle systems emitter should be disposed when the particle system is disposed
  14579. */ disposeEmitterOnDispose: boolean;
  14580. /**
  14581. * The current active Sub-systems, this property is used by the root particle system only.
  14582. */
  14583. activeSubSystems: Array<ParticleSystem>;
  14584. private _rootParticleSystem;
  14585. /**
  14586. * Gets the current list of active particles
  14587. */
  14588. readonly particles: Particle[];
  14589. /**
  14590. * Returns the string "ParticleSystem"
  14591. * @returns a string containing the class name
  14592. */
  14593. getClassName(): string;
  14594. /**
  14595. * Instantiates a particle system.
  14596. * 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.
  14597. * @param name The name of the particle system
  14598. * @param capacity The max number of particles alive at the same time
  14599. * @param scene The scene the particle system belongs to
  14600. * @param customEffect a custom effect used to change the way particles are rendered by default
  14601. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14602. * @param epsilon Offset used to render the particles
  14603. */
  14604. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14605. private _addFactorGradient;
  14606. private _removeFactorGradient;
  14607. /**
  14608. * Adds a new life time gradient
  14609. * @param gradient defines the gradient to use (between 0 and 1)
  14610. * @param factor defines the life time factor to affect to the specified gradient
  14611. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14612. * @returns the current particle system
  14613. */
  14614. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14615. /**
  14616. * Remove a specific life time gradient
  14617. * @param gradient defines the gradient to remove
  14618. * @returns the current particle system
  14619. */
  14620. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14621. /**
  14622. * Adds a new size gradient
  14623. * @param gradient defines the gradient to use (between 0 and 1)
  14624. * @param factor defines the size factor to affect to the specified gradient
  14625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14626. * @returns the current particle system
  14627. */
  14628. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14629. /**
  14630. * Remove a specific size gradient
  14631. * @param gradient defines the gradient to remove
  14632. * @returns the current particle system
  14633. */
  14634. removeSizeGradient(gradient: number): IParticleSystem;
  14635. /**
  14636. * Adds a new color remap gradient
  14637. * @param gradient defines the gradient to use (between 0 and 1)
  14638. * @param min defines the color remap minimal range
  14639. * @param max defines the color remap maximal range
  14640. * @returns the current particle system
  14641. */
  14642. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14643. /**
  14644. * Remove a specific color remap gradient
  14645. * @param gradient defines the gradient to remove
  14646. * @returns the current particle system
  14647. */
  14648. removeColorRemapGradient(gradient: number): IParticleSystem;
  14649. /**
  14650. * Adds a new alpha remap gradient
  14651. * @param gradient defines the gradient to use (between 0 and 1)
  14652. * @param min defines the alpha remap minimal range
  14653. * @param max defines the alpha remap maximal range
  14654. * @returns the current particle system
  14655. */
  14656. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14657. /**
  14658. * Remove a specific alpha remap gradient
  14659. * @param gradient defines the gradient to remove
  14660. * @returns the current particle system
  14661. */
  14662. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14663. /**
  14664. * Adds a new angular speed gradient
  14665. * @param gradient defines the gradient to use (between 0 and 1)
  14666. * @param factor defines the angular speed to affect to the specified gradient
  14667. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14668. * @returns the current particle system
  14669. */
  14670. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14671. /**
  14672. * Remove a specific angular speed gradient
  14673. * @param gradient defines the gradient to remove
  14674. * @returns the current particle system
  14675. */
  14676. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14677. /**
  14678. * Adds a new velocity gradient
  14679. * @param gradient defines the gradient to use (between 0 and 1)
  14680. * @param factor defines the velocity to affect to the specified gradient
  14681. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14682. * @returns the current particle system
  14683. */
  14684. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14685. /**
  14686. * Remove a specific velocity gradient
  14687. * @param gradient defines the gradient to remove
  14688. * @returns the current particle system
  14689. */
  14690. removeVelocityGradient(gradient: number): IParticleSystem;
  14691. /**
  14692. * Adds a new limit velocity gradient
  14693. * @param gradient defines the gradient to use (between 0 and 1)
  14694. * @param factor defines the limit velocity value to affect to the specified gradient
  14695. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14696. * @returns the current particle system
  14697. */
  14698. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14699. /**
  14700. * Remove a specific limit velocity gradient
  14701. * @param gradient defines the gradient to remove
  14702. * @returns the current particle system
  14703. */
  14704. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14705. /**
  14706. * Adds a new drag gradient
  14707. * @param gradient defines the gradient to use (between 0 and 1)
  14708. * @param factor defines the drag value to affect to the specified gradient
  14709. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14710. * @returns the current particle system
  14711. */
  14712. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14713. /**
  14714. * Remove a specific drag gradient
  14715. * @param gradient defines the gradient to remove
  14716. * @returns the current particle system
  14717. */
  14718. removeDragGradient(gradient: number): IParticleSystem;
  14719. /**
  14720. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14721. * @param gradient defines the gradient to use (between 0 and 1)
  14722. * @param factor defines the emit rate value to affect to the specified gradient
  14723. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14724. * @returns the current particle system
  14725. */
  14726. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14727. /**
  14728. * Remove a specific emit rate gradient
  14729. * @param gradient defines the gradient to remove
  14730. * @returns the current particle system
  14731. */
  14732. removeEmitRateGradient(gradient: number): IParticleSystem;
  14733. /**
  14734. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14735. * @param gradient defines the gradient to use (between 0 and 1)
  14736. * @param factor defines the start size value to affect to the specified gradient
  14737. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14738. * @returns the current particle system
  14739. */
  14740. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14741. /**
  14742. * Remove a specific start size gradient
  14743. * @param gradient defines the gradient to remove
  14744. * @returns the current particle system
  14745. */
  14746. removeStartSizeGradient(gradient: number): IParticleSystem;
  14747. private _createRampGradientTexture;
  14748. /**
  14749. * Gets the current list of ramp gradients.
  14750. * You must use addRampGradient and removeRampGradient to udpate this list
  14751. * @returns the list of ramp gradients
  14752. */
  14753. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14754. /**
  14755. * Adds a new ramp gradient used to remap particle colors
  14756. * @param gradient defines the gradient to use (between 0 and 1)
  14757. * @param color defines the color to affect to the specified gradient
  14758. * @returns the current particle system
  14759. */
  14760. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14761. /**
  14762. * Remove a specific ramp gradient
  14763. * @param gradient defines the gradient to remove
  14764. * @returns the current particle system
  14765. */
  14766. removeRampGradient(gradient: number): ParticleSystem;
  14767. /**
  14768. * Adds a new color gradient
  14769. * @param gradient defines the gradient to use (between 0 and 1)
  14770. * @param color1 defines the color to affect to the specified gradient
  14771. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14772. * @returns this particle system
  14773. */
  14774. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14775. /**
  14776. * Remove a specific color gradient
  14777. * @param gradient defines the gradient to remove
  14778. * @returns this particle system
  14779. */
  14780. removeColorGradient(gradient: number): IParticleSystem;
  14781. private _fetchR;
  14782. protected _reset(): void;
  14783. private _resetEffect;
  14784. private _createVertexBuffers;
  14785. private _createIndexBuffer;
  14786. /**
  14787. * Gets the maximum number of particles active at the same time.
  14788. * @returns The max number of active particles.
  14789. */
  14790. getCapacity(): number;
  14791. /**
  14792. * Gets whether there are still active particles in the system.
  14793. * @returns True if it is alive, otherwise false.
  14794. */
  14795. isAlive(): boolean;
  14796. /**
  14797. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14798. * @returns True if it has been started, otherwise false.
  14799. */
  14800. isStarted(): boolean;
  14801. private _prepareSubEmitterInternalArray;
  14802. /**
  14803. * Starts the particle system and begins to emit
  14804. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14805. */
  14806. start(delay?: number): void;
  14807. /**
  14808. * Stops the particle system.
  14809. * @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.
  14810. */
  14811. stop(stopSubEmitters?: boolean): void;
  14812. /**
  14813. * Remove all active particles
  14814. */
  14815. reset(): void;
  14816. /**
  14817. * @hidden (for internal use only)
  14818. */ appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14819. /**
  14820. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14821. * Its lifetime will start back at 0.
  14822. */
  14823. recycleParticle: (particle: Particle) => void;
  14824. private _stopSubEmitters;
  14825. private _createParticle;
  14826. private _removeFromRoot;
  14827. private _emitFromParticle;
  14828. private _update;
  14829. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  14830. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  14831. /** @hidden */
  14832. private _getEffect;
  14833. /**
  14834. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14835. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  14836. */
  14837. animate(preWarmOnly?: boolean): void;
  14838. private _appendParticleVertices;
  14839. /**
  14840. * Rebuilds the particle system.
  14841. */
  14842. rebuild(): void;
  14843. /**
  14844. * Is this system ready to be used/rendered
  14845. * @return true if the system is ready
  14846. */
  14847. isReady(): boolean;
  14848. private _render;
  14849. /**
  14850. * Renders the particle system in its current state.
  14851. * @returns the current number of particles
  14852. */
  14853. render(): number;
  14854. /**
  14855. * Disposes the particle system and free the associated resources
  14856. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14857. */
  14858. dispose(disposeTexture?: boolean): void;
  14859. /**
  14860. * Clones the particle system.
  14861. * @param name The name of the cloned object
  14862. * @param newEmitter The new emitter to use
  14863. * @returns the cloned particle system
  14864. */
  14865. clone(name: string, newEmitter: any): ParticleSystem;
  14866. /**
  14867. * Serializes the particle system to a JSON object.
  14868. * @returns the JSON object
  14869. */
  14870. serialize(): any;
  14871. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  14872. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  14873. /**
  14874. * Parses a JSON object to create a particle system.
  14875. * @param parsedParticleSystem The JSON object to parse
  14876. * @param scene The scene to create the particle system in
  14877. * @param rootUrl The root url to use to load external dependencies like texture
  14878. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  14879. * @returns the Parsed particle system
  14880. */
  14881. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  14882. }
  14883. }
  14884. declare module BABYLON {
  14885. /**
  14886. * A particle represents one of the element emitted by a particle system.
  14887. * This is mainly define by its coordinates, direction, velocity and age.
  14888. */
  14889. export class Particle {
  14890. /**
  14891. * The particle system the particle belongs to.
  14892. */
  14893. particleSystem: ParticleSystem;
  14894. private static _Count;
  14895. /**
  14896. * Unique ID of the particle
  14897. */
  14898. id: number;
  14899. /**
  14900. * The world position of the particle in the scene.
  14901. */
  14902. position: Vector3;
  14903. /**
  14904. * The world direction of the particle in the scene.
  14905. */
  14906. direction: Vector3;
  14907. /**
  14908. * The color of the particle.
  14909. */
  14910. color: Color4;
  14911. /**
  14912. * The color change of the particle per step.
  14913. */
  14914. colorStep: Color4;
  14915. /**
  14916. * Defines how long will the life of the particle be.
  14917. */
  14918. lifeTime: number;
  14919. /**
  14920. * The current age of the particle.
  14921. */
  14922. age: number;
  14923. /**
  14924. * The current size of the particle.
  14925. */
  14926. size: number;
  14927. /**
  14928. * The current scale of the particle.
  14929. */
  14930. scale: Vector2;
  14931. /**
  14932. * The current angle of the particle.
  14933. */
  14934. angle: number;
  14935. /**
  14936. * Defines how fast is the angle changing.
  14937. */
  14938. angularSpeed: number;
  14939. /**
  14940. * Defines the cell index used by the particle to be rendered from a sprite.
  14941. */
  14942. cellIndex: number;
  14943. /**
  14944. * The information required to support color remapping
  14945. */
  14946. remapData: Vector4;
  14947. /** @hidden */ randomCellOffset?: number;
  14948. /** @hidden */ initialDirection: Nullable<Vector3>;
  14949. /** @hidden */ attachedSubEmitters: Nullable<Array<SubEmitter>>;
  14950. /** @hidden */ initialStartSpriteCellID: number;
  14951. /** @hidden */ initialEndSpriteCellID: number;
  14952. /** @hidden */ currentColorGradient: Nullable<ColorGradient>;
  14953. /** @hidden */ currentColor1: Color4;
  14954. /** @hidden */ currentColor2: Color4;
  14955. /** @hidden */ currentSizeGradient: Nullable<FactorGradient>;
  14956. /** @hidden */ currentSize1: number;
  14957. /** @hidden */ currentSize2: number;
  14958. /** @hidden */ currentAngularSpeedGradient: Nullable<FactorGradient>;
  14959. /** @hidden */ currentAngularSpeed1: number;
  14960. /** @hidden */ currentAngularSpeed2: number;
  14961. /** @hidden */ currentVelocityGradient: Nullable<FactorGradient>;
  14962. /** @hidden */ currentVelocity1: number;
  14963. /** @hidden */ currentVelocity2: number;
  14964. /** @hidden */ currentLimitVelocityGradient: Nullable<FactorGradient>;
  14965. /** @hidden */ currentLimitVelocity1: number;
  14966. /** @hidden */ currentLimitVelocity2: number;
  14967. /** @hidden */ currentDragGradient: Nullable<FactorGradient>;
  14968. /** @hidden */ currentDrag1: number;
  14969. /** @hidden */ currentDrag2: number;
  14970. /** @hidden */ randomNoiseCoordinates1: Vector3;
  14971. /** @hidden */ randomNoiseCoordinates2: Vector3;
  14972. /**
  14973. * Creates a new instance Particle
  14974. * @param particleSystem the particle system the particle belongs to
  14975. */
  14976. constructor(
  14977. /**
  14978. * The particle system the particle belongs to.
  14979. */
  14980. particleSystem: ParticleSystem);
  14981. private updateCellInfoFromSystem;
  14982. /**
  14983. * Defines how the sprite cell index is updated for the particle
  14984. */
  14985. updateCellIndex(): void;
  14986. /** @hidden */ inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  14987. /** @hidden */ inheritParticleInfoToSubEmitters(): void;
  14988. /** @hidden */ reset(): void;
  14989. /**
  14990. * Copy the properties of particle to another one.
  14991. * @param other the particle to copy the information to.
  14992. */
  14993. copyTo(other: Particle): void;
  14994. }
  14995. }
  14996. declare module BABYLON {
  14997. /**
  14998. * Particle emitter represents a volume emitting particles.
  14999. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15000. */
  15001. export interface IParticleEmitterType {
  15002. /**
  15003. * Called by the particle System when the direction is computed for the created particle.
  15004. * @param worldMatrix is the world matrix of the particle system
  15005. * @param directionToUpdate is the direction vector to update with the result
  15006. * @param particle is the particle we are computed the direction for
  15007. */
  15008. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15009. /**
  15010. * Called by the particle System when the position is computed for the created particle.
  15011. * @param worldMatrix is the world matrix of the particle system
  15012. * @param positionToUpdate is the position vector to update with the result
  15013. * @param particle is the particle we are computed the position for
  15014. */
  15015. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15016. /**
  15017. * Clones the current emitter and returns a copy of it
  15018. * @returns the new emitter
  15019. */
  15020. clone(): IParticleEmitterType;
  15021. /**
  15022. * Called by the GPUParticleSystem to setup the update shader
  15023. * @param effect defines the update shader
  15024. */
  15025. applyToShader(effect: Effect): void;
  15026. /**
  15027. * Returns a string to use to update the GPU particles update shader
  15028. * @returns the effect defines string
  15029. */
  15030. getEffectDefines(): string;
  15031. /**
  15032. * Returns a string representing the class name
  15033. * @returns a string containing the class name
  15034. */
  15035. getClassName(): string;
  15036. /**
  15037. * Serializes the particle system to a JSON object.
  15038. * @returns the JSON object
  15039. */
  15040. serialize(): any;
  15041. /**
  15042. * Parse properties from a JSON object
  15043. * @param serializationObject defines the JSON object
  15044. */
  15045. parse(serializationObject: any): void;
  15046. }
  15047. }
  15048. declare module BABYLON {
  15049. /**
  15050. * Particle emitter emitting particles from the inside of a box.
  15051. * It emits the particles randomly between 2 given directions.
  15052. */
  15053. export class BoxParticleEmitter implements IParticleEmitterType {
  15054. /**
  15055. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15056. */
  15057. direction1: Vector3;
  15058. /**
  15059. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15060. */
  15061. direction2: Vector3;
  15062. /**
  15063. * 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.
  15064. */
  15065. minEmitBox: Vector3;
  15066. /**
  15067. * 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.
  15068. */
  15069. maxEmitBox: Vector3;
  15070. /**
  15071. * Creates a new instance BoxParticleEmitter
  15072. */
  15073. constructor();
  15074. /**
  15075. * Called by the particle System when the direction is computed for the created particle.
  15076. * @param worldMatrix is the world matrix of the particle system
  15077. * @param directionToUpdate is the direction vector to update with the result
  15078. * @param particle is the particle we are computed the direction for
  15079. */
  15080. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15081. /**
  15082. * Called by the particle System when the position is computed for the created particle.
  15083. * @param worldMatrix is the world matrix of the particle system
  15084. * @param positionToUpdate is the position vector to update with the result
  15085. * @param particle is the particle we are computed the position for
  15086. */
  15087. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15088. /**
  15089. * Clones the current emitter and returns a copy of it
  15090. * @returns the new emitter
  15091. */
  15092. clone(): BoxParticleEmitter;
  15093. /**
  15094. * Called by the GPUParticleSystem to setup the update shader
  15095. * @param effect defines the update shader
  15096. */
  15097. applyToShader(effect: Effect): void;
  15098. /**
  15099. * Returns a string to use to update the GPU particles update shader
  15100. * @returns a string containng the defines string
  15101. */
  15102. getEffectDefines(): string;
  15103. /**
  15104. * Returns the string "BoxParticleEmitter"
  15105. * @returns a string containing the class name
  15106. */
  15107. getClassName(): string;
  15108. /**
  15109. * Serializes the particle system to a JSON object.
  15110. * @returns the JSON object
  15111. */
  15112. serialize(): any;
  15113. /**
  15114. * Parse properties from a JSON object
  15115. * @param serializationObject defines the JSON object
  15116. */
  15117. parse(serializationObject: any): void;
  15118. }
  15119. }
  15120. declare module BABYLON {
  15121. /**
  15122. * Particle emitter emitting particles from the inside of a cone.
  15123. * It emits the particles alongside the cone volume from the base to the particle.
  15124. * The emission direction might be randomized.
  15125. */
  15126. export class ConeParticleEmitter implements IParticleEmitterType {
  15127. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15128. directionRandomizer: number;
  15129. private _radius;
  15130. private _angle;
  15131. private _height;
  15132. /**
  15133. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15134. */
  15135. radiusRange: number;
  15136. /**
  15137. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15138. */
  15139. heightRange: number;
  15140. /**
  15141. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15142. */
  15143. emitFromSpawnPointOnly: boolean;
  15144. /**
  15145. * Gets or sets the radius of the emission cone
  15146. */
  15147. radius: number;
  15148. /**
  15149. * Gets or sets the angle of the emission cone
  15150. */
  15151. angle: number;
  15152. private _buildHeight;
  15153. /**
  15154. * Creates a new instance ConeParticleEmitter
  15155. * @param radius the radius of the emission cone (1 by default)
  15156. * @param angle the cone base angle (PI by default)
  15157. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15158. */
  15159. constructor(radius?: number, angle?: number,
  15160. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15161. directionRandomizer?: number);
  15162. /**
  15163. * Called by the particle System when the direction is computed for the created particle.
  15164. * @param worldMatrix is the world matrix of the particle system
  15165. * @param directionToUpdate is the direction vector to update with the result
  15166. * @param particle is the particle we are computed the direction for
  15167. */
  15168. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15169. /**
  15170. * Called by the particle System when the position is computed for the created particle.
  15171. * @param worldMatrix is the world matrix of the particle system
  15172. * @param positionToUpdate is the position vector to update with the result
  15173. * @param particle is the particle we are computed the position for
  15174. */
  15175. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15176. /**
  15177. * Clones the current emitter and returns a copy of it
  15178. * @returns the new emitter
  15179. */
  15180. clone(): ConeParticleEmitter;
  15181. /**
  15182. * Called by the GPUParticleSystem to setup the update shader
  15183. * @param effect defines the update shader
  15184. */
  15185. applyToShader(effect: Effect): void;
  15186. /**
  15187. * Returns a string to use to update the GPU particles update shader
  15188. * @returns a string containng the defines string
  15189. */
  15190. getEffectDefines(): string;
  15191. /**
  15192. * Returns the string "ConeParticleEmitter"
  15193. * @returns a string containing the class name
  15194. */
  15195. getClassName(): string;
  15196. /**
  15197. * Serializes the particle system to a JSON object.
  15198. * @returns the JSON object
  15199. */
  15200. serialize(): any;
  15201. /**
  15202. * Parse properties from a JSON object
  15203. * @param serializationObject defines the JSON object
  15204. */
  15205. parse(serializationObject: any): void;
  15206. }
  15207. }
  15208. declare module BABYLON {
  15209. /**
  15210. * Particle emitter emitting particles from the inside of a cylinder.
  15211. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15212. */
  15213. export class CylinderParticleEmitter implements IParticleEmitterType {
  15214. /**
  15215. * The radius of the emission cylinder.
  15216. */
  15217. radius: number;
  15218. /**
  15219. * The height of the emission cylinder.
  15220. */
  15221. height: number;
  15222. /**
  15223. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15224. */
  15225. radiusRange: number;
  15226. /**
  15227. * How much to randomize the particle direction [0-1].
  15228. */
  15229. directionRandomizer: number;
  15230. /**
  15231. * Creates a new instance CylinderParticleEmitter
  15232. * @param radius the radius of the emission cylinder (1 by default)
  15233. * @param height the height of the emission cylinder (1 by default)
  15234. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15235. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15236. */
  15237. constructor(
  15238. /**
  15239. * The radius of the emission cylinder.
  15240. */
  15241. radius?: number,
  15242. /**
  15243. * The height of the emission cylinder.
  15244. */
  15245. height?: number,
  15246. /**
  15247. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15248. */
  15249. radiusRange?: number,
  15250. /**
  15251. * How much to randomize the particle direction [0-1].
  15252. */
  15253. directionRandomizer?: number);
  15254. /**
  15255. * Called by the particle System when the direction is computed for the created particle.
  15256. * @param worldMatrix is the world matrix of the particle system
  15257. * @param directionToUpdate is the direction vector to update with the result
  15258. * @param particle is the particle we are computed the direction for
  15259. */
  15260. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15261. /**
  15262. * Called by the particle System when the position is computed for the created particle.
  15263. * @param worldMatrix is the world matrix of the particle system
  15264. * @param positionToUpdate is the position vector to update with the result
  15265. * @param particle is the particle we are computed the position for
  15266. */
  15267. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15268. /**
  15269. * Clones the current emitter and returns a copy of it
  15270. * @returns the new emitter
  15271. */
  15272. clone(): CylinderParticleEmitter;
  15273. /**
  15274. * Called by the GPUParticleSystem to setup the update shader
  15275. * @param effect defines the update shader
  15276. */
  15277. applyToShader(effect: Effect): void;
  15278. /**
  15279. * Returns a string to use to update the GPU particles update shader
  15280. * @returns a string containng the defines string
  15281. */
  15282. getEffectDefines(): string;
  15283. /**
  15284. * Returns the string "CylinderParticleEmitter"
  15285. * @returns a string containing the class name
  15286. */
  15287. getClassName(): string;
  15288. /**
  15289. * Serializes the particle system to a JSON object.
  15290. * @returns the JSON object
  15291. */
  15292. serialize(): any;
  15293. /**
  15294. * Parse properties from a JSON object
  15295. * @param serializationObject defines the JSON object
  15296. */
  15297. parse(serializationObject: any): void;
  15298. }
  15299. /**
  15300. * Particle emitter emitting particles from the inside of a cylinder.
  15301. * It emits the particles randomly between two vectors.
  15302. */
  15303. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15304. /**
  15305. * The min limit of the emission direction.
  15306. */
  15307. direction1: Vector3;
  15308. /**
  15309. * The max limit of the emission direction.
  15310. */
  15311. direction2: Vector3;
  15312. /**
  15313. * Creates a new instance CylinderDirectedParticleEmitter
  15314. * @param radius the radius of the emission cylinder (1 by default)
  15315. * @param height the height of the emission cylinder (1 by default)
  15316. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15317. * @param direction1 the min limit of the emission direction (up vector by default)
  15318. * @param direction2 the max limit of the emission direction (up vector by default)
  15319. */
  15320. constructor(radius?: number, height?: number, radiusRange?: number,
  15321. /**
  15322. * The min limit of the emission direction.
  15323. */
  15324. direction1?: Vector3,
  15325. /**
  15326. * The max limit of the emission direction.
  15327. */
  15328. direction2?: Vector3);
  15329. /**
  15330. * Called by the particle System when the direction is computed for the created particle.
  15331. * @param worldMatrix is the world matrix of the particle system
  15332. * @param directionToUpdate is the direction vector to update with the result
  15333. * @param particle is the particle we are computed the direction for
  15334. */
  15335. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15336. /**
  15337. * Clones the current emitter and returns a copy of it
  15338. * @returns the new emitter
  15339. */
  15340. clone(): CylinderDirectedParticleEmitter;
  15341. /**
  15342. * Called by the GPUParticleSystem to setup the update shader
  15343. * @param effect defines the update shader
  15344. */
  15345. applyToShader(effect: Effect): void;
  15346. /**
  15347. * Returns a string to use to update the GPU particles update shader
  15348. * @returns a string containng the defines string
  15349. */
  15350. getEffectDefines(): string;
  15351. /**
  15352. * Returns the string "CylinderDirectedParticleEmitter"
  15353. * @returns a string containing the class name
  15354. */
  15355. getClassName(): string;
  15356. /**
  15357. * Serializes the particle system to a JSON object.
  15358. * @returns the JSON object
  15359. */
  15360. serialize(): any;
  15361. /**
  15362. * Parse properties from a JSON object
  15363. * @param serializationObject defines the JSON object
  15364. */
  15365. parse(serializationObject: any): void;
  15366. }
  15367. }
  15368. declare module BABYLON {
  15369. /**
  15370. * Particle emitter emitting particles from the inside of a hemisphere.
  15371. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15372. */
  15373. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15374. /**
  15375. * The radius of the emission hemisphere.
  15376. */
  15377. radius: number;
  15378. /**
  15379. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15380. */
  15381. radiusRange: number;
  15382. /**
  15383. * How much to randomize the particle direction [0-1].
  15384. */
  15385. directionRandomizer: number;
  15386. /**
  15387. * Creates a new instance HemisphericParticleEmitter
  15388. * @param radius the radius of the emission hemisphere (1 by default)
  15389. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15390. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15391. */
  15392. constructor(
  15393. /**
  15394. * The radius of the emission hemisphere.
  15395. */
  15396. radius?: number,
  15397. /**
  15398. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15399. */
  15400. radiusRange?: number,
  15401. /**
  15402. * How much to randomize the particle direction [0-1].
  15403. */
  15404. directionRandomizer?: number);
  15405. /**
  15406. * Called by the particle System when the direction is computed for the created particle.
  15407. * @param worldMatrix is the world matrix of the particle system
  15408. * @param directionToUpdate is the direction vector to update with the result
  15409. * @param particle is the particle we are computed the direction for
  15410. */
  15411. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15412. /**
  15413. * Called by the particle System when the position is computed for the created particle.
  15414. * @param worldMatrix is the world matrix of the particle system
  15415. * @param positionToUpdate is the position vector to update with the result
  15416. * @param particle is the particle we are computed the position for
  15417. */
  15418. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15419. /**
  15420. * Clones the current emitter and returns a copy of it
  15421. * @returns the new emitter
  15422. */
  15423. clone(): HemisphericParticleEmitter;
  15424. /**
  15425. * Called by the GPUParticleSystem to setup the update shader
  15426. * @param effect defines the update shader
  15427. */
  15428. applyToShader(effect: Effect): void;
  15429. /**
  15430. * Returns a string to use to update the GPU particles update shader
  15431. * @returns a string containng the defines string
  15432. */
  15433. getEffectDefines(): string;
  15434. /**
  15435. * Returns the string "HemisphericParticleEmitter"
  15436. * @returns a string containing the class name
  15437. */
  15438. getClassName(): string;
  15439. /**
  15440. * Serializes the particle system to a JSON object.
  15441. * @returns the JSON object
  15442. */
  15443. serialize(): any;
  15444. /**
  15445. * Parse properties from a JSON object
  15446. * @param serializationObject defines the JSON object
  15447. */
  15448. parse(serializationObject: any): void;
  15449. }
  15450. }
  15451. declare module BABYLON {
  15452. /**
  15453. * Particle emitter emitting particles from a point.
  15454. * It emits the particles randomly between 2 given directions.
  15455. */
  15456. export class PointParticleEmitter implements IParticleEmitterType {
  15457. /**
  15458. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15459. */
  15460. direction1: Vector3;
  15461. /**
  15462. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15463. */
  15464. direction2: Vector3;
  15465. /**
  15466. * Creates a new instance PointParticleEmitter
  15467. */
  15468. constructor();
  15469. /**
  15470. * Called by the particle System when the direction is computed for the created particle.
  15471. * @param worldMatrix is the world matrix of the particle system
  15472. * @param directionToUpdate is the direction vector to update with the result
  15473. * @param particle is the particle we are computed the direction for
  15474. */
  15475. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15476. /**
  15477. * Called by the particle System when the position is computed for the created particle.
  15478. * @param worldMatrix is the world matrix of the particle system
  15479. * @param positionToUpdate is the position vector to update with the result
  15480. * @param particle is the particle we are computed the position for
  15481. */
  15482. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15483. /**
  15484. * Clones the current emitter and returns a copy of it
  15485. * @returns the new emitter
  15486. */
  15487. clone(): PointParticleEmitter;
  15488. /**
  15489. * Called by the GPUParticleSystem to setup the update shader
  15490. * @param effect defines the update shader
  15491. */
  15492. applyToShader(effect: Effect): void;
  15493. /**
  15494. * Returns a string to use to update the GPU particles update shader
  15495. * @returns a string containng the defines string
  15496. */
  15497. getEffectDefines(): string;
  15498. /**
  15499. * Returns the string "PointParticleEmitter"
  15500. * @returns a string containing the class name
  15501. */
  15502. getClassName(): string;
  15503. /**
  15504. * Serializes the particle system to a JSON object.
  15505. * @returns the JSON object
  15506. */
  15507. serialize(): any;
  15508. /**
  15509. * Parse properties from a JSON object
  15510. * @param serializationObject defines the JSON object
  15511. */
  15512. parse(serializationObject: any): void;
  15513. }
  15514. }
  15515. declare module BABYLON {
  15516. /**
  15517. * Particle emitter emitting particles from the inside of a sphere.
  15518. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15519. */
  15520. export class SphereParticleEmitter implements IParticleEmitterType {
  15521. /**
  15522. * The radius of the emission sphere.
  15523. */
  15524. radius: number;
  15525. /**
  15526. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15527. */
  15528. radiusRange: number;
  15529. /**
  15530. * How much to randomize the particle direction [0-1].
  15531. */
  15532. directionRandomizer: number;
  15533. /**
  15534. * Creates a new instance SphereParticleEmitter
  15535. * @param radius the radius of the emission sphere (1 by default)
  15536. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15537. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15538. */
  15539. constructor(
  15540. /**
  15541. * The radius of the emission sphere.
  15542. */
  15543. radius?: number,
  15544. /**
  15545. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15546. */
  15547. radiusRange?: number,
  15548. /**
  15549. * How much to randomize the particle direction [0-1].
  15550. */
  15551. directionRandomizer?: number);
  15552. /**
  15553. * Called by the particle System when the direction is computed for the created particle.
  15554. * @param worldMatrix is the world matrix of the particle system
  15555. * @param directionToUpdate is the direction vector to update with the result
  15556. * @param particle is the particle we are computed the direction for
  15557. */
  15558. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15559. /**
  15560. * Called by the particle System when the position is computed for the created particle.
  15561. * @param worldMatrix is the world matrix of the particle system
  15562. * @param positionToUpdate is the position vector to update with the result
  15563. * @param particle is the particle we are computed the position for
  15564. */
  15565. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15566. /**
  15567. * Clones the current emitter and returns a copy of it
  15568. * @returns the new emitter
  15569. */
  15570. clone(): SphereParticleEmitter;
  15571. /**
  15572. * Called by the GPUParticleSystem to setup the update shader
  15573. * @param effect defines the update shader
  15574. */
  15575. applyToShader(effect: Effect): void;
  15576. /**
  15577. * Returns a string to use to update the GPU particles update shader
  15578. * @returns a string containng the defines string
  15579. */
  15580. getEffectDefines(): string;
  15581. /**
  15582. * Returns the string "SphereParticleEmitter"
  15583. * @returns a string containing the class name
  15584. */
  15585. getClassName(): string;
  15586. /**
  15587. * Serializes the particle system to a JSON object.
  15588. * @returns the JSON object
  15589. */
  15590. serialize(): any;
  15591. /**
  15592. * Parse properties from a JSON object
  15593. * @param serializationObject defines the JSON object
  15594. */
  15595. parse(serializationObject: any): void;
  15596. }
  15597. /**
  15598. * Particle emitter emitting particles from the inside of a sphere.
  15599. * It emits the particles randomly between two vectors.
  15600. */
  15601. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15602. /**
  15603. * The min limit of the emission direction.
  15604. */
  15605. direction1: Vector3;
  15606. /**
  15607. * The max limit of the emission direction.
  15608. */
  15609. direction2: Vector3;
  15610. /**
  15611. * Creates a new instance SphereDirectedParticleEmitter
  15612. * @param radius the radius of the emission sphere (1 by default)
  15613. * @param direction1 the min limit of the emission direction (up vector by default)
  15614. * @param direction2 the max limit of the emission direction (up vector by default)
  15615. */
  15616. constructor(radius?: number,
  15617. /**
  15618. * The min limit of the emission direction.
  15619. */
  15620. direction1?: Vector3,
  15621. /**
  15622. * The max limit of the emission direction.
  15623. */
  15624. direction2?: Vector3);
  15625. /**
  15626. * Called by the particle System when the direction is computed for the created particle.
  15627. * @param worldMatrix is the world matrix of the particle system
  15628. * @param directionToUpdate is the direction vector to update with the result
  15629. * @param particle is the particle we are computed the direction for
  15630. */
  15631. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15632. /**
  15633. * Clones the current emitter and returns a copy of it
  15634. * @returns the new emitter
  15635. */
  15636. clone(): SphereDirectedParticleEmitter;
  15637. /**
  15638. * Called by the GPUParticleSystem to setup the update shader
  15639. * @param effect defines the update shader
  15640. */
  15641. applyToShader(effect: Effect): void;
  15642. /**
  15643. * Returns a string to use to update the GPU particles update shader
  15644. * @returns a string containng the defines string
  15645. */
  15646. getEffectDefines(): string;
  15647. /**
  15648. * Returns the string "SphereDirectedParticleEmitter"
  15649. * @returns a string containing the class name
  15650. */
  15651. getClassName(): string;
  15652. /**
  15653. * Serializes the particle system to a JSON object.
  15654. * @returns the JSON object
  15655. */
  15656. serialize(): any;
  15657. /**
  15658. * Parse properties from a JSON object
  15659. * @param serializationObject defines the JSON object
  15660. */
  15661. parse(serializationObject: any): void;
  15662. }
  15663. }
  15664. declare module BABYLON {
  15665. /**
  15666. * Interface representing a particle system in Babylon.js.
  15667. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15668. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15669. */
  15670. export interface IParticleSystem {
  15671. /**
  15672. * List of animations used by the particle system.
  15673. */
  15674. animations: Animation[];
  15675. /**
  15676. * The id of the Particle system.
  15677. */
  15678. id: string;
  15679. /**
  15680. * The name of the Particle system.
  15681. */
  15682. name: string;
  15683. /**
  15684. * The emitter represents the Mesh or position we are attaching the particle system to.
  15685. */
  15686. emitter: Nullable<AbstractMesh | Vector3>;
  15687. /**
  15688. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15689. */
  15690. isBillboardBased: boolean;
  15691. /**
  15692. * The rendering group used by the Particle system to chose when to render.
  15693. */
  15694. renderingGroupId: number;
  15695. /**
  15696. * The layer mask we are rendering the particles through.
  15697. */
  15698. layerMask: number;
  15699. /**
  15700. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15701. */
  15702. updateSpeed: number;
  15703. /**
  15704. * The amount of time the particle system is running (depends of the overall update speed).
  15705. */
  15706. targetStopDuration: number;
  15707. /**
  15708. * The texture used to render each particle. (this can be a spritesheet)
  15709. */
  15710. particleTexture: Nullable<Texture>;
  15711. /**
  15712. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15713. */
  15714. blendMode: number;
  15715. /**
  15716. * Minimum life time of emitting particles.
  15717. */
  15718. minLifeTime: number;
  15719. /**
  15720. * Maximum life time of emitting particles.
  15721. */
  15722. maxLifeTime: number;
  15723. /**
  15724. * Minimum Size of emitting particles.
  15725. */
  15726. minSize: number;
  15727. /**
  15728. * Maximum Size of emitting particles.
  15729. */
  15730. maxSize: number;
  15731. /**
  15732. * Minimum scale of emitting particles on X axis.
  15733. */
  15734. minScaleX: number;
  15735. /**
  15736. * Maximum scale of emitting particles on X axis.
  15737. */
  15738. maxScaleX: number;
  15739. /**
  15740. * Minimum scale of emitting particles on Y axis.
  15741. */
  15742. minScaleY: number;
  15743. /**
  15744. * Maximum scale of emitting particles on Y axis.
  15745. */
  15746. maxScaleY: number;
  15747. /**
  15748. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15749. */
  15750. color1: Color4;
  15751. /**
  15752. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15753. */
  15754. color2: Color4;
  15755. /**
  15756. * Color the particle will have at the end of its lifetime.
  15757. */
  15758. colorDead: Color4;
  15759. /**
  15760. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15761. */
  15762. emitRate: number;
  15763. /**
  15764. * You can use gravity if you want to give an orientation to your particles.
  15765. */
  15766. gravity: Vector3;
  15767. /**
  15768. * Minimum power of emitting particles.
  15769. */
  15770. minEmitPower: number;
  15771. /**
  15772. * Maximum power of emitting particles.
  15773. */
  15774. maxEmitPower: number;
  15775. /**
  15776. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15777. */
  15778. minAngularSpeed: number;
  15779. /**
  15780. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15781. */
  15782. maxAngularSpeed: number;
  15783. /**
  15784. * Gets or sets the minimal initial rotation in radians.
  15785. */
  15786. minInitialRotation: number;
  15787. /**
  15788. * Gets or sets the maximal initial rotation in radians.
  15789. */
  15790. maxInitialRotation: number;
  15791. /**
  15792. * The particle emitter type defines the emitter used by the particle system.
  15793. * It can be for example box, sphere, or cone...
  15794. */
  15795. particleEmitterType: Nullable<IParticleEmitterType>;
  15796. /**
  15797. * Defines the delay in milliseconds before starting the system (0 by default)
  15798. */
  15799. startDelay: number;
  15800. /**
  15801. * 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
  15802. */
  15803. preWarmCycles: number;
  15804. /**
  15805. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  15806. */
  15807. preWarmStepOffset: number;
  15808. /**
  15809. * 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)
  15810. */
  15811. spriteCellChangeSpeed: number;
  15812. /**
  15813. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15814. */
  15815. startSpriteCellID: number;
  15816. /**
  15817. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15818. */
  15819. endSpriteCellID: number;
  15820. /**
  15821. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15822. */
  15823. spriteCellWidth: number;
  15824. /**
  15825. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15826. */
  15827. spriteCellHeight: number;
  15828. /**
  15829. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15830. */
  15831. spriteRandomStartCell: boolean;
  15832. /**
  15833. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  15834. */
  15835. isAnimationSheetEnabled: boolean;
  15836. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15837. translationPivot: Vector2;
  15838. /**
  15839. * Gets or sets a texture used to add random noise to particle positions
  15840. */
  15841. noiseTexture: Nullable<BaseTexture>;
  15842. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15843. noiseStrength: Vector3;
  15844. /**
  15845. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15846. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15847. */
  15848. billboardMode: number;
  15849. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15850. limitVelocityDamping: number;
  15851. /**
  15852. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15853. */
  15854. beginAnimationOnStart: boolean;
  15855. /**
  15856. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15857. */
  15858. beginAnimationFrom: number;
  15859. /**
  15860. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15861. */
  15862. beginAnimationTo: number;
  15863. /**
  15864. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15865. */
  15866. beginAnimationLoop: boolean;
  15867. /**
  15868. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15869. */
  15870. disposeOnStop: boolean;
  15871. /**
  15872. * Gets the maximum number of particles active at the same time.
  15873. * @returns The max number of active particles.
  15874. */
  15875. getCapacity(): number;
  15876. /**
  15877. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15878. * @returns True if it has been started, otherwise false.
  15879. */
  15880. isStarted(): boolean;
  15881. /**
  15882. * Animates the particle system for this frame.
  15883. */
  15884. animate(): void;
  15885. /**
  15886. * Renders the particle system in its current state.
  15887. * @returns the current number of particles
  15888. */
  15889. render(): number;
  15890. /**
  15891. * Dispose the particle system and frees its associated resources.
  15892. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15893. */
  15894. dispose(disposeTexture?: boolean): void;
  15895. /**
  15896. * Clones the particle system.
  15897. * @param name The name of the cloned object
  15898. * @param newEmitter The new emitter to use
  15899. * @returns the cloned particle system
  15900. */
  15901. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  15902. /**
  15903. * Serializes the particle system to a JSON object.
  15904. * @returns the JSON object
  15905. */
  15906. serialize(): any;
  15907. /**
  15908. * Rebuild the particle system
  15909. */
  15910. rebuild(): void;
  15911. /**
  15912. * Starts the particle system and begins to emit
  15913. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  15914. */
  15915. start(delay?: number): void;
  15916. /**
  15917. * Stops the particle system.
  15918. */
  15919. stop(): void;
  15920. /**
  15921. * Remove all active particles
  15922. */
  15923. reset(): void;
  15924. /**
  15925. * Is this system ready to be used/rendered
  15926. * @return true if the system is ready
  15927. */
  15928. isReady(): boolean;
  15929. /**
  15930. * Adds a new color gradient
  15931. * @param gradient defines the gradient to use (between 0 and 1)
  15932. * @param color1 defines the color to affect to the specified gradient
  15933. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15934. * @returns the current particle system
  15935. */
  15936. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15937. /**
  15938. * Remove a specific color gradient
  15939. * @param gradient defines the gradient to remove
  15940. * @returns the current particle system
  15941. */
  15942. removeColorGradient(gradient: number): IParticleSystem;
  15943. /**
  15944. * Adds a new size gradient
  15945. * @param gradient defines the gradient to use (between 0 and 1)
  15946. * @param factor defines the size factor to affect to the specified gradient
  15947. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15948. * @returns the current particle system
  15949. */
  15950. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15951. /**
  15952. * Remove a specific size gradient
  15953. * @param gradient defines the gradient to remove
  15954. * @returns the current particle system
  15955. */
  15956. removeSizeGradient(gradient: number): IParticleSystem;
  15957. /**
  15958. * Gets the current list of color gradients.
  15959. * You must use addColorGradient and removeColorGradient to udpate this list
  15960. * @returns the list of color gradients
  15961. */
  15962. getColorGradients(): Nullable<Array<ColorGradient>>;
  15963. /**
  15964. * Gets the current list of size gradients.
  15965. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15966. * @returns the list of size gradients
  15967. */
  15968. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15969. /**
  15970. * Gets the current list of angular speed gradients.
  15971. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15972. * @returns the list of angular speed gradients
  15973. */
  15974. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15975. /**
  15976. * Adds a new angular speed gradient
  15977. * @param gradient defines the gradient to use (between 0 and 1)
  15978. * @param factor defines the angular speed to affect to the specified gradient
  15979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15980. * @returns the current particle system
  15981. */
  15982. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15983. /**
  15984. * Remove a specific angular speed gradient
  15985. * @param gradient defines the gradient to remove
  15986. * @returns the current particle system
  15987. */
  15988. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15989. /**
  15990. * Gets the current list of velocity gradients.
  15991. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15992. * @returns the list of velocity gradients
  15993. */
  15994. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15995. /**
  15996. * Adds a new velocity gradient
  15997. * @param gradient defines the gradient to use (between 0 and 1)
  15998. * @param factor defines the velocity to affect to the specified gradient
  15999. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16000. * @returns the current particle system
  16001. */
  16002. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16003. /**
  16004. * Remove a specific velocity gradient
  16005. * @param gradient defines the gradient to remove
  16006. * @returns the current particle system
  16007. */
  16008. removeVelocityGradient(gradient: number): IParticleSystem;
  16009. /**
  16010. * Gets the current list of limit velocity gradients.
  16011. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16012. * @returns the list of limit velocity gradients
  16013. */
  16014. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16015. /**
  16016. * Adds a new limit velocity gradient
  16017. * @param gradient defines the gradient to use (between 0 and 1)
  16018. * @param factor defines the limit velocity to affect to the specified gradient
  16019. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16020. * @returns the current particle system
  16021. */
  16022. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16023. /**
  16024. * Remove a specific limit velocity gradient
  16025. * @param gradient defines the gradient to remove
  16026. * @returns the current particle system
  16027. */
  16028. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16029. /**
  16030. * Adds a new drag gradient
  16031. * @param gradient defines the gradient to use (between 0 and 1)
  16032. * @param factor defines the drag to affect to the specified gradient
  16033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16034. * @returns the current particle system
  16035. */
  16036. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16037. /**
  16038. * Remove a specific drag gradient
  16039. * @param gradient defines the gradient to remove
  16040. * @returns the current particle system
  16041. */
  16042. removeDragGradient(gradient: number): IParticleSystem;
  16043. /**
  16044. * Gets the current list of drag gradients.
  16045. * You must use addDragGradient and removeDragGradient to udpate this list
  16046. * @returns the list of drag gradients
  16047. */
  16048. getDragGradients(): Nullable<Array<FactorGradient>>;
  16049. /**
  16050. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16051. * @param gradient defines the gradient to use (between 0 and 1)
  16052. * @param factor defines the emit rate to affect to the specified gradient
  16053. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16054. * @returns the current particle system
  16055. */
  16056. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16057. /**
  16058. * Remove a specific emit rate gradient
  16059. * @param gradient defines the gradient to remove
  16060. * @returns the current particle system
  16061. */
  16062. removeEmitRateGradient(gradient: number): IParticleSystem;
  16063. /**
  16064. * Gets the current list of emit rate gradients.
  16065. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16066. * @returns the list of emit rate gradients
  16067. */
  16068. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16069. /**
  16070. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16071. * @param gradient defines the gradient to use (between 0 and 1)
  16072. * @param factor defines the start size to affect to the specified gradient
  16073. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16074. * @returns the current particle system
  16075. */
  16076. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16077. /**
  16078. * Remove a specific start size gradient
  16079. * @param gradient defines the gradient to remove
  16080. * @returns the current particle system
  16081. */
  16082. removeStartSizeGradient(gradient: number): IParticleSystem;
  16083. /**
  16084. * Gets the current list of start size gradients.
  16085. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16086. * @returns the list of start size gradients
  16087. */
  16088. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16089. /**
  16090. * Adds a new life time gradient
  16091. * @param gradient defines the gradient to use (between 0 and 1)
  16092. * @param factor defines the life time factor to affect to the specified gradient
  16093. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16094. * @returns the current particle system
  16095. */
  16096. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16097. /**
  16098. * Remove a specific life time gradient
  16099. * @param gradient defines the gradient to remove
  16100. * @returns the current particle system
  16101. */
  16102. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16103. /**
  16104. * Gets the current list of life time gradients.
  16105. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16106. * @returns the list of life time gradients
  16107. */
  16108. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16109. /**
  16110. * Gets the current list of color gradients.
  16111. * You must use addColorGradient and removeColorGradient to udpate this list
  16112. * @returns the list of color gradients
  16113. */
  16114. getColorGradients(): Nullable<Array<ColorGradient>>;
  16115. /**
  16116. * Adds a new ramp gradient used to remap particle colors
  16117. * @param gradient defines the gradient to use (between 0 and 1)
  16118. * @param color defines the color to affect to the specified gradient
  16119. * @returns the current particle system
  16120. */
  16121. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16122. /**
  16123. * Gets the current list of ramp gradients.
  16124. * You must use addRampGradient and removeRampGradient to udpate this list
  16125. * @returns the list of ramp gradients
  16126. */
  16127. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16128. /** Gets or sets a boolean indicating that ramp gradients must be used
  16129. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16130. */
  16131. useRampGradients: boolean;
  16132. /**
  16133. * Adds a new color remap gradient
  16134. * @param gradient defines the gradient to use (between 0 and 1)
  16135. * @param min defines the color remap minimal range
  16136. * @param max defines the color remap maximal range
  16137. * @returns the current particle system
  16138. */
  16139. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16140. /**
  16141. * Gets the current list of color remap gradients.
  16142. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16143. * @returns the list of color remap gradients
  16144. */
  16145. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16146. /**
  16147. * Adds a new alpha remap gradient
  16148. * @param gradient defines the gradient to use (between 0 and 1)
  16149. * @param min defines the alpha remap minimal range
  16150. * @param max defines the alpha remap maximal range
  16151. * @returns the current particle system
  16152. */
  16153. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16154. /**
  16155. * Gets the current list of alpha remap gradients.
  16156. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16157. * @returns the list of alpha remap gradients
  16158. */
  16159. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16160. /**
  16161. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16162. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16163. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16164. * @returns the emitter
  16165. */
  16166. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16167. /**
  16168. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16169. * @param radius The radius of the hemisphere to emit from
  16170. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16171. * @returns the emitter
  16172. */
  16173. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16174. /**
  16175. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16176. * @param radius The radius of the sphere to emit from
  16177. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16178. * @returns the emitter
  16179. */
  16180. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16181. /**
  16182. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16183. * @param radius The radius of the sphere to emit from
  16184. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16185. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16186. * @returns the emitter
  16187. */
  16188. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16189. /**
  16190. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16191. * @param radius The radius of the emission cylinder
  16192. * @param height The height of the emission cylinder
  16193. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16194. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16195. * @returns the emitter
  16196. */
  16197. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16198. /**
  16199. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16200. * @param radius The radius of the cylinder to emit from
  16201. * @param height The height of the emission cylinder
  16202. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16203. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16204. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16205. * @returns the emitter
  16206. */
  16207. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16208. /**
  16209. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16210. * @param radius The radius of the cone to emit from
  16211. * @param angle The base angle of the cone
  16212. * @returns the emitter
  16213. */
  16214. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16215. /**
  16216. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16217. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16218. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16219. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16220. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16221. * @returns the emitter
  16222. */
  16223. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16224. /**
  16225. * Get hosting scene
  16226. * @returns the scene
  16227. */
  16228. getScene(): Scene;
  16229. }
  16230. }
  16231. declare module BABYLON {
  16232. /**
  16233. * Creates an instance based on a source mesh.
  16234. */
  16235. export class InstancedMesh extends AbstractMesh {
  16236. private _sourceMesh;
  16237. private _currentLOD;
  16238. /** @hidden */ indexInSourceMeshInstanceArray: number;
  16239. constructor(name: string, source: Mesh);
  16240. /**
  16241. * Returns the string "InstancedMesh".
  16242. */
  16243. getClassName(): string;
  16244. /**
  16245. * If the source mesh receives shadows
  16246. */
  16247. readonly receiveShadows: boolean;
  16248. /**
  16249. * The material of the source mesh
  16250. */
  16251. readonly material: Nullable<Material>;
  16252. /**
  16253. * Visibility of the source mesh
  16254. */
  16255. readonly visibility: number;
  16256. /**
  16257. * Skeleton of the source mesh
  16258. */
  16259. readonly skeleton: Nullable<Skeleton>;
  16260. /**
  16261. * Rendering ground id of the source mesh
  16262. */
  16263. renderingGroupId: number;
  16264. /**
  16265. * Returns the total number of vertices (integer).
  16266. */
  16267. getTotalVertices(): number;
  16268. /**
  16269. * Returns a positive integer : the total number of indices in this mesh geometry.
  16270. * @returns the numner of indices or zero if the mesh has no geometry.
  16271. */
  16272. getTotalIndices(): number;
  16273. /**
  16274. * The source mesh of the instance
  16275. */
  16276. readonly sourceMesh: Mesh;
  16277. /**
  16278. * Is this node ready to be used/rendered
  16279. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16280. * @return {boolean} is it ready
  16281. */
  16282. isReady(completeCheck?: boolean): boolean;
  16283. /**
  16284. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16285. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16286. * @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.
  16287. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16288. */
  16289. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16290. /**
  16291. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16292. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16293. * The `data` are either a numeric array either a Float32Array.
  16294. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16295. * 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).
  16296. * Note that a new underlying VertexBuffer object is created each call.
  16297. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16298. *
  16299. * Possible `kind` values :
  16300. * - VertexBuffer.PositionKind
  16301. * - VertexBuffer.UVKind
  16302. * - VertexBuffer.UV2Kind
  16303. * - VertexBuffer.UV3Kind
  16304. * - VertexBuffer.UV4Kind
  16305. * - VertexBuffer.UV5Kind
  16306. * - VertexBuffer.UV6Kind
  16307. * - VertexBuffer.ColorKind
  16308. * - VertexBuffer.MatricesIndicesKind
  16309. * - VertexBuffer.MatricesIndicesExtraKind
  16310. * - VertexBuffer.MatricesWeightsKind
  16311. * - VertexBuffer.MatricesWeightsExtraKind
  16312. *
  16313. * Returns the Mesh.
  16314. */
  16315. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16316. /**
  16317. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16318. * If the mesh has no geometry, it is simply returned as it is.
  16319. * The `data` are either a numeric array either a Float32Array.
  16320. * No new underlying VertexBuffer object is created.
  16321. * 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.
  16322. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16323. *
  16324. * Possible `kind` values :
  16325. * - VertexBuffer.PositionKind
  16326. * - VertexBuffer.UVKind
  16327. * - VertexBuffer.UV2Kind
  16328. * - VertexBuffer.UV3Kind
  16329. * - VertexBuffer.UV4Kind
  16330. * - VertexBuffer.UV5Kind
  16331. * - VertexBuffer.UV6Kind
  16332. * - VertexBuffer.ColorKind
  16333. * - VertexBuffer.MatricesIndicesKind
  16334. * - VertexBuffer.MatricesIndicesExtraKind
  16335. * - VertexBuffer.MatricesWeightsKind
  16336. * - VertexBuffer.MatricesWeightsExtraKind
  16337. *
  16338. * Returns the Mesh.
  16339. */
  16340. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16341. /**
  16342. * Sets the mesh indices.
  16343. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16344. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16345. * This method creates a new index buffer each call.
  16346. * Returns the Mesh.
  16347. */
  16348. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16349. /**
  16350. * Boolean : True if the mesh owns the requested kind of data.
  16351. */
  16352. isVerticesDataPresent(kind: string): boolean;
  16353. /**
  16354. * Returns an array of indices (IndicesArray).
  16355. */
  16356. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  16357. /**
  16358. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16359. * This means the mesh underlying bounding box and sphere are recomputed.
  16360. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16361. * @returns the current mesh
  16362. */
  16363. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16364. /** @hidden */ preActivate(): InstancedMesh;
  16365. /** @hidden */ activate(renderId: number): InstancedMesh;
  16366. /**
  16367. * Returns the current associated LOD AbstractMesh.
  16368. */
  16369. getLOD(camera: Camera): AbstractMesh;
  16370. /** @hidden */ syncSubMeshes(): InstancedMesh;
  16371. /** @hidden */ generatePointsArray(): boolean;
  16372. /**
  16373. * Creates a new InstancedMesh from the current mesh.
  16374. * - name (string) : the cloned mesh name
  16375. * - newParent (optional Node) : the optional Node to parent the clone to.
  16376. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16377. *
  16378. * Returns the clone.
  16379. */
  16380. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16381. /**
  16382. * Disposes the InstancedMesh.
  16383. * Returns nothing.
  16384. */
  16385. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16386. }
  16387. }
  16388. declare module BABYLON {
  16389. /**
  16390. * Defines the options associated with the creation of a shader material.
  16391. */
  16392. export interface IShaderMaterialOptions {
  16393. /**
  16394. * Does the material work in alpha blend mode
  16395. */
  16396. needAlphaBlending: boolean;
  16397. /**
  16398. * Does the material work in alpha test mode
  16399. */
  16400. needAlphaTesting: boolean;
  16401. /**
  16402. * The list of attribute names used in the shader
  16403. */
  16404. attributes: string[];
  16405. /**
  16406. * The list of unifrom names used in the shader
  16407. */
  16408. uniforms: string[];
  16409. /**
  16410. * The list of UBO names used in the shader
  16411. */
  16412. uniformBuffers: string[];
  16413. /**
  16414. * The list of sampler names used in the shader
  16415. */
  16416. samplers: string[];
  16417. /**
  16418. * The list of defines used in the shader
  16419. */
  16420. defines: string[];
  16421. }
  16422. /**
  16423. * 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.
  16424. *
  16425. * This returned material effects how the mesh will look based on the code in the shaders.
  16426. *
  16427. * @see http://doc.babylonjs.com/how_to/shader_material
  16428. */
  16429. export class ShaderMaterial extends Material {
  16430. private _shaderPath;
  16431. private _options;
  16432. private _textures;
  16433. private _textureArrays;
  16434. private _floats;
  16435. private _ints;
  16436. private _floatsArrays;
  16437. private _colors3;
  16438. private _colors3Arrays;
  16439. private _colors4;
  16440. private _vectors2;
  16441. private _vectors3;
  16442. private _vectors4;
  16443. private _matrices;
  16444. private _matrices3x3;
  16445. private _matrices2x2;
  16446. private _vectors2Arrays;
  16447. private _vectors3Arrays;
  16448. private _cachedWorldViewMatrix;
  16449. private _renderId;
  16450. /**
  16451. * Instantiate a new shader material.
  16452. * 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.
  16453. * This returned material effects how the mesh will look based on the code in the shaders.
  16454. * @see http://doc.babylonjs.com/how_to/shader_material
  16455. * @param name Define the name of the material in the scene
  16456. * @param scene Define the scene the material belongs to
  16457. * @param shaderPath Defines the route to the shader code in one of three ways:
  16458. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16459. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16460. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16461. * @param options Define the options used to create the shader
  16462. */
  16463. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16464. /**
  16465. * Gets the options used to compile the shader.
  16466. * They can be modified to trigger a new compilation
  16467. */
  16468. readonly options: IShaderMaterialOptions;
  16469. /**
  16470. * Gets the current class name of the material e.g. "ShaderMaterial"
  16471. * Mainly use in serialization.
  16472. * @returns the class name
  16473. */
  16474. getClassName(): string;
  16475. /**
  16476. * Specifies if the material will require alpha blending
  16477. * @returns a boolean specifying if alpha blending is needed
  16478. */
  16479. needAlphaBlending(): boolean;
  16480. /**
  16481. * Specifies if this material should be rendered in alpha test mode
  16482. * @returns a boolean specifying if an alpha test is needed.
  16483. */
  16484. needAlphaTesting(): boolean;
  16485. private _checkUniform;
  16486. /**
  16487. * Set a texture in the shader.
  16488. * @param name Define the name of the uniform samplers as defined in the shader
  16489. * @param texture Define the texture to bind to this sampler
  16490. * @return the material itself allowing "fluent" like uniform updates
  16491. */
  16492. setTexture(name: string, texture: Texture): ShaderMaterial;
  16493. /**
  16494. * Set a texture array in the shader.
  16495. * @param name Define the name of the uniform sampler array as defined in the shader
  16496. * @param textures Define the list of textures to bind to this sampler
  16497. * @return the material itself allowing "fluent" like uniform updates
  16498. */
  16499. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16500. /**
  16501. * Set a float in the shader.
  16502. * @param name Define the name of the uniform as defined in the shader
  16503. * @param value Define the value to give to the uniform
  16504. * @return the material itself allowing "fluent" like uniform updates
  16505. */
  16506. setFloat(name: string, value: number): ShaderMaterial;
  16507. /**
  16508. * Set a int in the shader.
  16509. * @param name Define the name of the uniform as defined in the shader
  16510. * @param value Define the value to give to the uniform
  16511. * @return the material itself allowing "fluent" like uniform updates
  16512. */
  16513. setInt(name: string, value: number): ShaderMaterial;
  16514. /**
  16515. * Set an array of floats in the shader.
  16516. * @param name Define the name of the uniform as defined in the shader
  16517. * @param value Define the value to give to the uniform
  16518. * @return the material itself allowing "fluent" like uniform updates
  16519. */
  16520. setFloats(name: string, value: number[]): ShaderMaterial;
  16521. /**
  16522. * Set a vec3 in the shader from a Color3.
  16523. * @param name Define the name of the uniform as defined in the shader
  16524. * @param value Define the value to give to the uniform
  16525. * @return the material itself allowing "fluent" like uniform updates
  16526. */
  16527. setColor3(name: string, value: Color3): ShaderMaterial;
  16528. /**
  16529. * Set a vec3 array in the shader from a Color3 array.
  16530. * @param name Define the name of the uniform as defined in the shader
  16531. * @param value Define the value to give to the uniform
  16532. * @return the material itself allowing "fluent" like uniform updates
  16533. */
  16534. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16535. /**
  16536. * Set a vec4 in the shader from a Color4.
  16537. * @param name Define the name of the uniform as defined in the shader
  16538. * @param value Define the value to give to the uniform
  16539. * @return the material itself allowing "fluent" like uniform updates
  16540. */
  16541. setColor4(name: string, value: Color4): ShaderMaterial;
  16542. /**
  16543. * Set a vec2 in the shader from a Vector2.
  16544. * @param name Define the name of the uniform as defined in the shader
  16545. * @param value Define the value to give to the uniform
  16546. * @return the material itself allowing "fluent" like uniform updates
  16547. */
  16548. setVector2(name: string, value: Vector2): ShaderMaterial;
  16549. /**
  16550. * Set a vec3 in the shader from a Vector3.
  16551. * @param name Define the name of the uniform as defined in the shader
  16552. * @param value Define the value to give to the uniform
  16553. * @return the material itself allowing "fluent" like uniform updates
  16554. */
  16555. setVector3(name: string, value: Vector3): ShaderMaterial;
  16556. /**
  16557. * Set a vec4 in the shader from a Vector4.
  16558. * @param name Define the name of the uniform as defined in the shader
  16559. * @param value Define the value to give to the uniform
  16560. * @return the material itself allowing "fluent" like uniform updates
  16561. */
  16562. setVector4(name: string, value: Vector4): ShaderMaterial;
  16563. /**
  16564. * Set a mat4 in the shader from a Matrix.
  16565. * @param name Define the name of the uniform as defined in the shader
  16566. * @param value Define the value to give to the uniform
  16567. * @return the material itself allowing "fluent" like uniform updates
  16568. */
  16569. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16570. /**
  16571. * Set a mat3 in the shader from a Float32Array.
  16572. * @param name Define the name of the uniform as defined in the shader
  16573. * @param value Define the value to give to the uniform
  16574. * @return the material itself allowing "fluent" like uniform updates
  16575. */
  16576. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16577. /**
  16578. * Set a mat2 in the shader from a Float32Array.
  16579. * @param name Define the name of the uniform as defined in the shader
  16580. * @param value Define the value to give to the uniform
  16581. * @return the material itself allowing "fluent" like uniform updates
  16582. */
  16583. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16584. /**
  16585. * Set a vec2 array in the shader from a number array.
  16586. * @param name Define the name of the uniform as defined in the shader
  16587. * @param value Define the value to give to the uniform
  16588. * @return the material itself allowing "fluent" like uniform updates
  16589. */
  16590. setArray2(name: string, value: number[]): ShaderMaterial;
  16591. /**
  16592. * Set a vec3 array in the shader from a number array.
  16593. * @param name Define the name of the uniform as defined in the shader
  16594. * @param value Define the value to give to the uniform
  16595. * @return the material itself allowing "fluent" like uniform updates
  16596. */
  16597. setArray3(name: string, value: number[]): ShaderMaterial;
  16598. private _checkCache;
  16599. /**
  16600. * Specifies that the submesh is ready to be used
  16601. * @param mesh defines the mesh to check
  16602. * @param subMesh defines which submesh to check
  16603. * @param useInstances specifies that instances should be used
  16604. * @returns a boolean indicating that the submesh is ready or not
  16605. */
  16606. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16607. /**
  16608. * Checks if the material is ready to render the requested mesh
  16609. * @param mesh Define the mesh to render
  16610. * @param useInstances Define whether or not the material is used with instances
  16611. * @returns true if ready, otherwise false
  16612. */
  16613. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16614. /**
  16615. * Binds the world matrix to the material
  16616. * @param world defines the world transformation matrix
  16617. */
  16618. bindOnlyWorldMatrix(world: Matrix): void;
  16619. /**
  16620. * Binds the material to the mesh
  16621. * @param world defines the world transformation matrix
  16622. * @param mesh defines the mesh to bind the material to
  16623. */
  16624. bind(world: Matrix, mesh?: Mesh): void;
  16625. /**
  16626. * Gets the active textures from the material
  16627. * @returns an array of textures
  16628. */
  16629. getActiveTextures(): BaseTexture[];
  16630. /**
  16631. * Specifies if the material uses a texture
  16632. * @param texture defines the texture to check against the material
  16633. * @returns a boolean specifying if the material uses the texture
  16634. */
  16635. hasTexture(texture: BaseTexture): boolean;
  16636. /**
  16637. * Makes a duplicate of the material, and gives it a new name
  16638. * @param name defines the new name for the duplicated material
  16639. * @returns the cloned material
  16640. */
  16641. clone(name: string): ShaderMaterial;
  16642. /**
  16643. * Disposes the material
  16644. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16645. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16646. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16647. */
  16648. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16649. /**
  16650. * Serializes this material in a JSON representation
  16651. * @returns the serialized material object
  16652. */
  16653. serialize(): any;
  16654. /**
  16655. * Creates a shader material from parsed shader material data
  16656. * @param source defines the JSON represnetation of the material
  16657. * @param scene defines the hosting scene
  16658. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16659. * @returns a new material
  16660. */
  16661. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16662. }
  16663. }
  16664. declare module BABYLON {
  16665. /** @hidden */
  16666. export var colorPixelShader: {
  16667. name: string;
  16668. shader: string;
  16669. };
  16670. }
  16671. declare module BABYLON {
  16672. /** @hidden */
  16673. export var colorVertexShader: {
  16674. name: string;
  16675. shader: string;
  16676. };
  16677. }
  16678. declare module BABYLON {
  16679. /**
  16680. * Line mesh
  16681. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16682. */
  16683. export class LinesMesh extends Mesh {
  16684. /**
  16685. * If vertex color should be applied to the mesh
  16686. */
  16687. useVertexColor?: boolean | undefined;
  16688. /**
  16689. * If vertex alpha should be applied to the mesh
  16690. */
  16691. useVertexAlpha?: boolean | undefined;
  16692. /**
  16693. * Color of the line (Default: White)
  16694. */
  16695. color: Color3;
  16696. /**
  16697. * Alpha of the line (Default: 1)
  16698. */
  16699. alpha: number;
  16700. /**
  16701. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16702. * This margin is expressed in world space coordinates, so its value may vary.
  16703. * Default value is 0.1
  16704. */
  16705. intersectionThreshold: number;
  16706. private _colorShader;
  16707. /**
  16708. * Creates a new LinesMesh
  16709. * @param name defines the name
  16710. * @param scene defines the hosting scene
  16711. * @param parent defines the parent mesh if any
  16712. * @param source defines the optional source LinesMesh used to clone data from
  16713. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16714. * When false, achieved by calling a clone(), also passing False.
  16715. * This will make creation of children, recursive.
  16716. * @param useVertexColor defines if this LinesMesh supports vertex color
  16717. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16718. */
  16719. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16720. /**
  16721. * If vertex color should be applied to the mesh
  16722. */
  16723. useVertexColor?: boolean | undefined,
  16724. /**
  16725. * If vertex alpha should be applied to the mesh
  16726. */
  16727. useVertexAlpha?: boolean | undefined);
  16728. private _addClipPlaneDefine;
  16729. private _removeClipPlaneDefine;
  16730. isReady(): boolean;
  16731. /**
  16732. * Returns the string "LineMesh"
  16733. */
  16734. getClassName(): string;
  16735. /**
  16736. * @hidden
  16737. */
  16738. /**
  16739. * @hidden
  16740. */
  16741. material: Material;
  16742. /**
  16743. * @hidden
  16744. */
  16745. readonly checkCollisions: boolean;
  16746. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16747. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16748. /**
  16749. * Disposes of the line mesh
  16750. * @param doNotRecurse If children should be disposed
  16751. */
  16752. dispose(doNotRecurse?: boolean): void;
  16753. /**
  16754. * Returns a new LineMesh object cloned from the current one.
  16755. */
  16756. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16757. /**
  16758. * Creates a new InstancedLinesMesh object from the mesh model.
  16759. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16760. * @param name defines the name of the new instance
  16761. * @returns a new InstancedLinesMesh
  16762. */
  16763. createInstance(name: string): InstancedLinesMesh;
  16764. }
  16765. /**
  16766. * Creates an instance based on a source LinesMesh
  16767. */
  16768. export class InstancedLinesMesh extends InstancedMesh {
  16769. /**
  16770. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16771. * This margin is expressed in world space coordinates, so its value may vary.
  16772. * Initilized with the intersectionThreshold value of the source LinesMesh
  16773. */
  16774. intersectionThreshold: number;
  16775. constructor(name: string, source: LinesMesh);
  16776. /**
  16777. * Returns the string "InstancedLinesMesh".
  16778. */
  16779. getClassName(): string;
  16780. }
  16781. }
  16782. declare module BABYLON {
  16783. /** @hidden */
  16784. export var linePixelShader: {
  16785. name: string;
  16786. shader: string;
  16787. };
  16788. }
  16789. declare module BABYLON {
  16790. /** @hidden */
  16791. export var lineVertexShader: {
  16792. name: string;
  16793. shader: string;
  16794. };
  16795. }
  16796. declare module BABYLON {
  16797. interface AbstractMesh {
  16798. /**
  16799. * Disables the mesh edge rendering mode
  16800. * @returns the currentAbstractMesh
  16801. */
  16802. disableEdgesRendering(): AbstractMesh;
  16803. /**
  16804. * Enables the edge rendering mode on the mesh.
  16805. * This mode makes the mesh edges visible
  16806. * @param epsilon defines the maximal distance between two angles to detect a face
  16807. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16808. * @returns the currentAbstractMesh
  16809. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16810. */
  16811. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16812. /**
  16813. * Gets the edgesRenderer associated with the mesh
  16814. */
  16815. edgesRenderer: Nullable<EdgesRenderer>;
  16816. }
  16817. interface LinesMesh {
  16818. /**
  16819. * Enables the edge rendering mode on the mesh.
  16820. * This mode makes the mesh edges visible
  16821. * @param epsilon defines the maximal distance between two angles to detect a face
  16822. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16823. * @returns the currentAbstractMesh
  16824. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16825. */
  16826. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16827. }
  16828. interface InstancedLinesMesh {
  16829. /**
  16830. * Enables the edge rendering mode on the mesh.
  16831. * This mode makes the mesh edges visible
  16832. * @param epsilon defines the maximal distance between two angles to detect a face
  16833. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16834. * @returns the current InstancedLinesMesh
  16835. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16836. */
  16837. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16838. }
  16839. /**
  16840. * Defines the minimum contract an Edges renderer should follow.
  16841. */
  16842. export interface IEdgesRenderer extends IDisposable {
  16843. /**
  16844. * Gets or sets a boolean indicating if the edgesRenderer is active
  16845. */
  16846. isEnabled: boolean;
  16847. /**
  16848. * Renders the edges of the attached mesh,
  16849. */
  16850. render(): void;
  16851. /**
  16852. * Checks wether or not the edges renderer is ready to render.
  16853. * @return true if ready, otherwise false.
  16854. */
  16855. isReady(): boolean;
  16856. }
  16857. /**
  16858. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16859. */
  16860. export class EdgesRenderer implements IEdgesRenderer {
  16861. /**
  16862. * Define the size of the edges with an orthographic camera
  16863. */
  16864. edgesWidthScalerForOrthographic: number;
  16865. /**
  16866. * Define the size of the edges with a perspective camera
  16867. */
  16868. edgesWidthScalerForPerspective: number;
  16869. protected _source: AbstractMesh;
  16870. protected _linesPositions: number[];
  16871. protected _linesNormals: number[];
  16872. protected _linesIndices: number[];
  16873. protected _epsilon: number;
  16874. protected _indicesCount: number;
  16875. protected _lineShader: ShaderMaterial;
  16876. protected _ib: WebGLBuffer;
  16877. protected _buffers: {
  16878. [key: string]: Nullable<VertexBuffer>;
  16879. };
  16880. protected _checkVerticesInsteadOfIndices: boolean;
  16881. private _meshRebuildObserver;
  16882. private _meshDisposeObserver;
  16883. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16884. isEnabled: boolean;
  16885. /**
  16886. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16887. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16888. * @param source Mesh used to create edges
  16889. * @param epsilon sum of angles in adjacency to check for edge
  16890. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16891. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16892. */
  16893. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16894. protected _prepareRessources(): void;
  16895. /** @hidden */ rebuild(): void;
  16896. /**
  16897. * Releases the required resources for the edges renderer
  16898. */
  16899. dispose(): void;
  16900. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16901. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16902. /**
  16903. * Checks if the pair of p0 and p1 is en edge
  16904. * @param faceIndex
  16905. * @param edge
  16906. * @param faceNormals
  16907. * @param p0
  16908. * @param p1
  16909. * @private
  16910. */
  16911. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16912. /**
  16913. * push line into the position, normal and index buffer
  16914. * @protected
  16915. */
  16916. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16917. /**
  16918. * Generates lines edges from adjacencjes
  16919. * @private
  16920. */ generateEdgesLines(): void;
  16921. /**
  16922. * Checks wether or not the edges renderer is ready to render.
  16923. * @return true if ready, otherwise false.
  16924. */
  16925. isReady(): boolean;
  16926. /**
  16927. * Renders the edges of the attached mesh,
  16928. */
  16929. render(): void;
  16930. }
  16931. /**
  16932. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16933. */
  16934. export class LineEdgesRenderer extends EdgesRenderer {
  16935. /**
  16936. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16937. * @param source LineMesh used to generate edges
  16938. * @param epsilon not important (specified angle for edge detection)
  16939. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16940. */
  16941. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16942. /**
  16943. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16944. */ generateEdgesLines(): void;
  16945. }
  16946. }
  16947. declare module BABYLON {
  16948. /**
  16949. * This represents the object necessary to create a rendering group.
  16950. * This is exclusively used and created by the rendering manager.
  16951. * To modify the behavior, you use the available helpers in your scene or meshes.
  16952. * @hidden
  16953. */
  16954. export class RenderingGroup {
  16955. index: number;
  16956. private _scene;
  16957. private _opaqueSubMeshes;
  16958. private _transparentSubMeshes;
  16959. private _alphaTestSubMeshes;
  16960. private _depthOnlySubMeshes;
  16961. private _particleSystems;
  16962. private _spriteManagers;
  16963. private _opaqueSortCompareFn;
  16964. private _alphaTestSortCompareFn;
  16965. private _transparentSortCompareFn;
  16966. private _renderOpaque;
  16967. private _renderAlphaTest;
  16968. private _renderTransparent;
  16969. private _edgesRenderers;
  16970. onBeforeTransparentRendering: () => void;
  16971. /**
  16972. * Set the opaque sort comparison function.
  16973. * If null the sub meshes will be render in the order they were created
  16974. */
  16975. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16976. /**
  16977. * Set the alpha test sort comparison function.
  16978. * If null the sub meshes will be render in the order they were created
  16979. */
  16980. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16981. /**
  16982. * Set the transparent sort comparison function.
  16983. * If null the sub meshes will be render in the order they were created
  16984. */
  16985. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16986. /**
  16987. * Creates a new rendering group.
  16988. * @param index The rendering group index
  16989. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16990. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16991. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16992. */
  16993. 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>);
  16994. /**
  16995. * Render all the sub meshes contained in the group.
  16996. * @param customRenderFunction Used to override the default render behaviour of the group.
  16997. * @returns true if rendered some submeshes.
  16998. */
  16999. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17000. /**
  17001. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17002. * @param subMeshes The submeshes to render
  17003. */
  17004. private renderOpaqueSorted;
  17005. /**
  17006. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17007. * @param subMeshes The submeshes to render
  17008. */
  17009. private renderAlphaTestSorted;
  17010. /**
  17011. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17012. * @param subMeshes The submeshes to render
  17013. */
  17014. private renderTransparentSorted;
  17015. /**
  17016. * Renders the submeshes in a specified order.
  17017. * @param subMeshes The submeshes to sort before render
  17018. * @param sortCompareFn The comparison function use to sort
  17019. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17020. * @param transparent Specifies to activate blending if true
  17021. */
  17022. private static renderSorted;
  17023. /**
  17024. * Renders the submeshes in the order they were dispatched (no sort applied).
  17025. * @param subMeshes The submeshes to render
  17026. */
  17027. private static renderUnsorted;
  17028. /**
  17029. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17030. * are rendered back to front if in the same alpha index.
  17031. *
  17032. * @param a The first submesh
  17033. * @param b The second submesh
  17034. * @returns The result of the comparison
  17035. */
  17036. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17037. /**
  17038. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17039. * are rendered back to front.
  17040. *
  17041. * @param a The first submesh
  17042. * @param b The second submesh
  17043. * @returns The result of the comparison
  17044. */
  17045. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17046. /**
  17047. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17048. * are rendered front to back (prevent overdraw).
  17049. *
  17050. * @param a The first submesh
  17051. * @param b The second submesh
  17052. * @returns The result of the comparison
  17053. */
  17054. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17055. /**
  17056. * Resets the different lists of submeshes to prepare a new frame.
  17057. */
  17058. prepare(): void;
  17059. dispose(): void;
  17060. /**
  17061. * Inserts the submesh in its correct queue depending on its material.
  17062. * @param subMesh The submesh to dispatch
  17063. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17064. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17065. */
  17066. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17067. dispatchSprites(spriteManager: ISpriteManager): void;
  17068. dispatchParticles(particleSystem: IParticleSystem): void;
  17069. private _renderParticles;
  17070. private _renderSprites;
  17071. }
  17072. }
  17073. declare module BABYLON {
  17074. /**
  17075. * Interface describing the different options available in the rendering manager
  17076. * regarding Auto Clear between groups.
  17077. */
  17078. export interface IRenderingManagerAutoClearSetup {
  17079. /**
  17080. * Defines whether or not autoclear is enable.
  17081. */
  17082. autoClear: boolean;
  17083. /**
  17084. * Defines whether or not to autoclear the depth buffer.
  17085. */
  17086. depth: boolean;
  17087. /**
  17088. * Defines whether or not to autoclear the stencil buffer.
  17089. */
  17090. stencil: boolean;
  17091. }
  17092. /**
  17093. * This class is used by the onRenderingGroupObservable
  17094. */
  17095. export class RenderingGroupInfo {
  17096. /**
  17097. * The Scene that being rendered
  17098. */
  17099. scene: Scene;
  17100. /**
  17101. * The camera currently used for the rendering pass
  17102. */
  17103. camera: Nullable<Camera>;
  17104. /**
  17105. * The ID of the renderingGroup being processed
  17106. */
  17107. renderingGroupId: number;
  17108. }
  17109. /**
  17110. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17111. * It is enable to manage the different groups as well as the different necessary sort functions.
  17112. * This should not be used directly aside of the few static configurations
  17113. */
  17114. export class RenderingManager {
  17115. /**
  17116. * The max id used for rendering groups (not included)
  17117. */
  17118. static MAX_RENDERINGGROUPS: number;
  17119. /**
  17120. * The min id used for rendering groups (included)
  17121. */
  17122. static MIN_RENDERINGGROUPS: number;
  17123. /**
  17124. * Used to globally prevent autoclearing scenes.
  17125. */
  17126. static AUTOCLEAR: boolean;
  17127. /**
  17128. * @hidden
  17129. */ useSceneAutoClearSetup: boolean;
  17130. private _scene;
  17131. private _renderingGroups;
  17132. private _depthStencilBufferAlreadyCleaned;
  17133. private _autoClearDepthStencil;
  17134. private _customOpaqueSortCompareFn;
  17135. private _customAlphaTestSortCompareFn;
  17136. private _customTransparentSortCompareFn;
  17137. private _renderingGroupInfo;
  17138. /**
  17139. * Instantiates a new rendering group for a particular scene
  17140. * @param scene Defines the scene the groups belongs to
  17141. */
  17142. constructor(scene: Scene);
  17143. private _clearDepthStencilBuffer;
  17144. /**
  17145. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17146. * @hidden
  17147. */
  17148. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17149. /**
  17150. * Resets the different information of the group to prepare a new frame
  17151. * @hidden
  17152. */
  17153. reset(): void;
  17154. /**
  17155. * Dispose and release the group and its associated resources.
  17156. * @hidden
  17157. */
  17158. dispose(): void;
  17159. /**
  17160. * Clear the info related to rendering groups preventing retention points during dispose.
  17161. */
  17162. freeRenderingGroups(): void;
  17163. private _prepareRenderingGroup;
  17164. /**
  17165. * Add a sprite manager to the rendering manager in order to render it this frame.
  17166. * @param spriteManager Define the sprite manager to render
  17167. */
  17168. dispatchSprites(spriteManager: ISpriteManager): void;
  17169. /**
  17170. * Add a particle system to the rendering manager in order to render it this frame.
  17171. * @param particleSystem Define the particle system to render
  17172. */
  17173. dispatchParticles(particleSystem: IParticleSystem): void;
  17174. /**
  17175. * Add a submesh to the manager in order to render it this frame
  17176. * @param subMesh The submesh to dispatch
  17177. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17178. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17179. */
  17180. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17181. /**
  17182. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17183. * This allowed control for front to back rendering or reversly depending of the special needs.
  17184. *
  17185. * @param renderingGroupId The rendering group id corresponding to its index
  17186. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17187. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17188. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17189. */
  17190. 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;
  17191. /**
  17192. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17193. *
  17194. * @param renderingGroupId The rendering group id corresponding to its index
  17195. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17196. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17197. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17198. */
  17199. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17200. /**
  17201. * Gets the current auto clear configuration for one rendering group of the rendering
  17202. * manager.
  17203. * @param index the rendering group index to get the information for
  17204. * @returns The auto clear setup for the requested rendering group
  17205. */
  17206. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17207. }
  17208. }
  17209. declare module BABYLON {
  17210. /**
  17211. * This Helps creating a texture that will be created from a camera in your scene.
  17212. * It is basically a dynamic texture that could be used to create special effects for instance.
  17213. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17214. */
  17215. export class RenderTargetTexture extends Texture {
  17216. isCube: boolean;
  17217. /**
  17218. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17219. */
  17220. static readonly REFRESHRATE_RENDER_ONCE: number;
  17221. /**
  17222. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17223. */
  17224. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17225. /**
  17226. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17227. * the central point of your effect and can save a lot of performances.
  17228. */
  17229. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17230. /**
  17231. * Use this predicate to dynamically define the list of mesh you want to render.
  17232. * If set, the renderList property will be overwritten.
  17233. */
  17234. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17235. private _renderList;
  17236. /**
  17237. * Use this list to define the list of mesh you want to render.
  17238. */
  17239. renderList: Nullable<Array<AbstractMesh>>;
  17240. private _hookArray;
  17241. /**
  17242. * Define if particles should be rendered in your texture.
  17243. */
  17244. renderParticles: boolean;
  17245. /**
  17246. * Define if sprites should be rendered in your texture.
  17247. */
  17248. renderSprites: boolean;
  17249. /**
  17250. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17251. */
  17252. coordinatesMode: number;
  17253. /**
  17254. * Define the camera used to render the texture.
  17255. */
  17256. activeCamera: Nullable<Camera>;
  17257. /**
  17258. * Override the render function of the texture with your own one.
  17259. */
  17260. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17261. /**
  17262. * Define if camera post processes should be use while rendering the texture.
  17263. */
  17264. useCameraPostProcesses: boolean;
  17265. /**
  17266. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17267. */
  17268. ignoreCameraViewport: boolean;
  17269. private _postProcessManager;
  17270. private _postProcesses;
  17271. private _resizeObserver;
  17272. /**
  17273. * An event triggered when the texture is unbind.
  17274. */
  17275. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17276. /**
  17277. * An event triggered when the texture is unbind.
  17278. */
  17279. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17280. private _onAfterUnbindObserver;
  17281. /**
  17282. * Set a after unbind callback in the texture.
  17283. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17284. */
  17285. onAfterUnbind: () => void;
  17286. /**
  17287. * An event triggered before rendering the texture
  17288. */
  17289. onBeforeRenderObservable: Observable<number>;
  17290. private _onBeforeRenderObserver;
  17291. /**
  17292. * Set a before render callback in the texture.
  17293. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17294. */
  17295. onBeforeRender: (faceIndex: number) => void;
  17296. /**
  17297. * An event triggered after rendering the texture
  17298. */
  17299. onAfterRenderObservable: Observable<number>;
  17300. private _onAfterRenderObserver;
  17301. /**
  17302. * Set a after render callback in the texture.
  17303. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17304. */
  17305. onAfterRender: (faceIndex: number) => void;
  17306. /**
  17307. * An event triggered after the texture clear
  17308. */
  17309. onClearObservable: Observable<Engine>;
  17310. private _onClearObserver;
  17311. /**
  17312. * Set a clear callback in the texture.
  17313. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17314. */
  17315. onClear: (Engine: Engine) => void;
  17316. /**
  17317. * Define the clear color of the Render Target if it should be different from the scene.
  17318. */
  17319. clearColor: Color4;
  17320. protected _size: number | {
  17321. width: number;
  17322. height: number;
  17323. };
  17324. protected _initialSizeParameter: number | {
  17325. width: number;
  17326. height: number;
  17327. } | {
  17328. ratio: number;
  17329. };
  17330. protected _sizeRatio: Nullable<number>;
  17331. /** @hidden */ generateMipMaps: boolean;
  17332. protected _renderingManager: RenderingManager;
  17333. /** @hidden */ waitingRenderList: string[];
  17334. protected _doNotChangeAspectRatio: boolean;
  17335. protected _currentRefreshId: number;
  17336. protected _refreshRate: number;
  17337. protected _textureMatrix: Matrix;
  17338. protected _samples: number;
  17339. protected _renderTargetOptions: RenderTargetCreationOptions;
  17340. /**
  17341. * Gets render target creation options that were used.
  17342. */
  17343. readonly renderTargetOptions: RenderTargetCreationOptions;
  17344. protected _engine: Engine;
  17345. protected _onRatioRescale(): void;
  17346. /**
  17347. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17348. * It must define where the camera used to render the texture is set
  17349. */
  17350. boundingBoxPosition: Vector3;
  17351. private _boundingBoxSize;
  17352. /**
  17353. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17354. * When defined, the cubemap will switch to local mode
  17355. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17356. * @example https://www.babylonjs-playground.com/#RNASML
  17357. */
  17358. boundingBoxSize: Vector3;
  17359. /**
  17360. * In case the RTT has been created with a depth texture, get the associated
  17361. * depth texture.
  17362. * Otherwise, return null.
  17363. */
  17364. depthStencilTexture: Nullable<InternalTexture>;
  17365. /**
  17366. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17367. * or used a shadow, depth texture...
  17368. * @param name The friendly name of the texture
  17369. * @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)
  17370. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17371. * @param generateMipMaps True if mip maps need to be generated after render.
  17372. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17373. * @param type The type of the buffer in the RTT (int, half float, float...)
  17374. * @param isCube True if a cube texture needs to be created
  17375. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17376. * @param generateDepthBuffer True to generate a depth buffer
  17377. * @param generateStencilBuffer True to generate a stencil buffer
  17378. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17379. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17380. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17381. */
  17382. constructor(name: string, size: number | {
  17383. width: number;
  17384. height: number;
  17385. } | {
  17386. ratio: number;
  17387. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17388. /**
  17389. * Creates a depth stencil texture.
  17390. * This is only available in WebGL 2 or with the depth texture extension available.
  17391. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17392. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17393. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17394. */
  17395. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17396. private _processSizeParameter;
  17397. /**
  17398. * Define the number of samples to use in case of MSAA.
  17399. * It defaults to one meaning no MSAA has been enabled.
  17400. */
  17401. samples: number;
  17402. /**
  17403. * Resets the refresh counter of the texture and start bak from scratch.
  17404. * Could be useful to regenerate the texture if it is setup to render only once.
  17405. */
  17406. resetRefreshCounter(): void;
  17407. /**
  17408. * Define the refresh rate of the texture or the rendering frequency.
  17409. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17410. */
  17411. refreshRate: number;
  17412. /**
  17413. * Adds a post process to the render target rendering passes.
  17414. * @param postProcess define the post process to add
  17415. */
  17416. addPostProcess(postProcess: PostProcess): void;
  17417. /**
  17418. * Clear all the post processes attached to the render target
  17419. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17420. */
  17421. clearPostProcesses(dispose?: boolean): void;
  17422. /**
  17423. * Remove one of the post process from the list of attached post processes to the texture
  17424. * @param postProcess define the post process to remove from the list
  17425. */
  17426. removePostProcess(postProcess: PostProcess): void;
  17427. /** @hidden */ shouldRender(): boolean;
  17428. /**
  17429. * Gets the actual render size of the texture.
  17430. * @returns the width of the render size
  17431. */
  17432. getRenderSize(): number;
  17433. /**
  17434. * Gets the actual render width of the texture.
  17435. * @returns the width of the render size
  17436. */
  17437. getRenderWidth(): number;
  17438. /**
  17439. * Gets the actual render height of the texture.
  17440. * @returns the height of the render size
  17441. */
  17442. getRenderHeight(): number;
  17443. /**
  17444. * Get if the texture can be rescaled or not.
  17445. */
  17446. readonly canRescale: boolean;
  17447. /**
  17448. * Resize the texture using a ratio.
  17449. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17450. */
  17451. scale(ratio: number): void;
  17452. /**
  17453. * Get the texture reflection matrix used to rotate/transform the reflection.
  17454. * @returns the reflection matrix
  17455. */
  17456. getReflectionTextureMatrix(): Matrix;
  17457. /**
  17458. * Resize the texture to a new desired size.
  17459. * Be carrefull as it will recreate all the data in the new texture.
  17460. * @param size Define the new size. It can be:
  17461. * - a number for squared texture,
  17462. * - an object containing { width: number, height: number }
  17463. * - or an object containing a ratio { ratio: number }
  17464. */
  17465. resize(size: number | {
  17466. width: number;
  17467. height: number;
  17468. } | {
  17469. ratio: number;
  17470. }): void;
  17471. /**
  17472. * Renders all the objects from the render list into the texture.
  17473. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17474. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17475. */
  17476. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17477. private _bestReflectionRenderTargetDimension;
  17478. /**
  17479. * @hidden
  17480. * @param faceIndex face index to bind to if this is a cubetexture
  17481. */ bindFrameBuffer(faceIndex?: number): void;
  17482. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17483. private renderToTarget;
  17484. /**
  17485. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17486. * This allowed control for front to back rendering or reversly depending of the special needs.
  17487. *
  17488. * @param renderingGroupId The rendering group id corresponding to its index
  17489. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17490. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17491. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17492. */
  17493. 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;
  17494. /**
  17495. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17496. *
  17497. * @param renderingGroupId The rendering group id corresponding to its index
  17498. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17499. */
  17500. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17501. /**
  17502. * Clones the texture.
  17503. * @returns the cloned texture
  17504. */
  17505. clone(): RenderTargetTexture;
  17506. /**
  17507. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17508. * @returns The JSON representation of the texture
  17509. */
  17510. serialize(): any;
  17511. /**
  17512. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17513. */
  17514. disposeFramebufferObjects(): void;
  17515. /**
  17516. * Dispose the texture and release its associated resources.
  17517. */
  17518. dispose(): void;
  17519. /** @hidden */ rebuild(): void;
  17520. /**
  17521. * Clear the info related to rendering groups preventing retention point in material dispose.
  17522. */
  17523. freeRenderingGroups(): void;
  17524. /**
  17525. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17526. * @returns the view count
  17527. */
  17528. getViewCount(): number;
  17529. }
  17530. }
  17531. declare module BABYLON {
  17532. /**
  17533. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17534. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17535. * You can then easily use it as a reflectionTexture on a flat surface.
  17536. * In case the surface is not a plane, please consider relying on reflection probes.
  17537. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17538. */
  17539. export class MirrorTexture extends RenderTargetTexture {
  17540. private scene;
  17541. /**
  17542. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17543. * 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.
  17544. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17545. */
  17546. mirrorPlane: Plane;
  17547. /**
  17548. * Define the blur ratio used to blur the reflection if needed.
  17549. */
  17550. blurRatio: number;
  17551. /**
  17552. * Define the adaptive blur kernel used to blur the reflection if needed.
  17553. * This will autocompute the closest best match for the `blurKernel`
  17554. */
  17555. adaptiveBlurKernel: number;
  17556. /**
  17557. * Define the blur kernel used to blur the reflection if needed.
  17558. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17559. */
  17560. blurKernel: number;
  17561. /**
  17562. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17563. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17564. */
  17565. blurKernelX: number;
  17566. /**
  17567. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17568. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17569. */
  17570. blurKernelY: number;
  17571. private _autoComputeBlurKernel;
  17572. protected _onRatioRescale(): void;
  17573. private _updateGammaSpace;
  17574. private _imageProcessingConfigChangeObserver;
  17575. private _transformMatrix;
  17576. private _mirrorMatrix;
  17577. private _savedViewMatrix;
  17578. private _blurX;
  17579. private _blurY;
  17580. private _adaptiveBlurKernel;
  17581. private _blurKernelX;
  17582. private _blurKernelY;
  17583. private _blurRatio;
  17584. /**
  17585. * Instantiates a Mirror Texture.
  17586. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17587. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17588. * You can then easily use it as a reflectionTexture on a flat surface.
  17589. * In case the surface is not a plane, please consider relying on reflection probes.
  17590. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17591. * @param name
  17592. * @param size
  17593. * @param scene
  17594. * @param generateMipMaps
  17595. * @param type
  17596. * @param samplingMode
  17597. * @param generateDepthBuffer
  17598. */
  17599. constructor(name: string, size: number | {
  17600. width: number;
  17601. height: number;
  17602. } | {
  17603. ratio: number;
  17604. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17605. private _preparePostProcesses;
  17606. /**
  17607. * Clone the mirror texture.
  17608. * @returns the cloned texture
  17609. */
  17610. clone(): MirrorTexture;
  17611. /**
  17612. * Serialize the texture to a JSON representation you could use in Parse later on
  17613. * @returns the serialized JSON representation
  17614. */
  17615. serialize(): any;
  17616. /**
  17617. * Dispose the texture and release its associated resources.
  17618. */
  17619. dispose(): void;
  17620. }
  17621. }
  17622. declare module BABYLON {
  17623. /**
  17624. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17625. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17626. */
  17627. export class Texture extends BaseTexture {
  17628. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17629. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17630. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17631. /** nearest is mag = nearest and min = nearest and mip = linear */
  17632. static readonly NEAREST_SAMPLINGMODE: number;
  17633. /** nearest is mag = nearest and min = nearest and mip = linear */
  17634. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17635. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17636. static readonly BILINEAR_SAMPLINGMODE: number;
  17637. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17638. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17639. /** Trilinear is mag = linear and min = linear and mip = linear */
  17640. static readonly TRILINEAR_SAMPLINGMODE: number;
  17641. /** Trilinear is mag = linear and min = linear and mip = linear */
  17642. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17643. /** mag = nearest and min = nearest and mip = nearest */
  17644. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17645. /** mag = nearest and min = linear and mip = nearest */
  17646. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17647. /** mag = nearest and min = linear and mip = linear */
  17648. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17649. /** mag = nearest and min = linear and mip = none */
  17650. static readonly NEAREST_LINEAR: number;
  17651. /** mag = nearest and min = nearest and mip = none */
  17652. static readonly NEAREST_NEAREST: number;
  17653. /** mag = linear and min = nearest and mip = nearest */
  17654. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17655. /** mag = linear and min = nearest and mip = linear */
  17656. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17657. /** mag = linear and min = linear and mip = none */
  17658. static readonly LINEAR_LINEAR: number;
  17659. /** mag = linear and min = nearest and mip = none */
  17660. static readonly LINEAR_NEAREST: number;
  17661. /** Explicit coordinates mode */
  17662. static readonly EXPLICIT_MODE: number;
  17663. /** Spherical coordinates mode */
  17664. static readonly SPHERICAL_MODE: number;
  17665. /** Planar coordinates mode */
  17666. static readonly PLANAR_MODE: number;
  17667. /** Cubic coordinates mode */
  17668. static readonly CUBIC_MODE: number;
  17669. /** Projection coordinates mode */
  17670. static readonly PROJECTION_MODE: number;
  17671. /** Inverse Cubic coordinates mode */
  17672. static readonly SKYBOX_MODE: number;
  17673. /** Inverse Cubic coordinates mode */
  17674. static readonly INVCUBIC_MODE: number;
  17675. /** Equirectangular coordinates mode */
  17676. static readonly EQUIRECTANGULAR_MODE: number;
  17677. /** Equirectangular Fixed coordinates mode */
  17678. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17679. /** Equirectangular Fixed Mirrored coordinates mode */
  17680. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17681. /** Texture is not repeating outside of 0..1 UVs */
  17682. static readonly CLAMP_ADDRESSMODE: number;
  17683. /** Texture is repeating outside of 0..1 UVs */
  17684. static readonly WRAP_ADDRESSMODE: number;
  17685. /** Texture is repeating and mirrored */
  17686. static readonly MIRROR_ADDRESSMODE: number;
  17687. /**
  17688. * 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
  17689. */
  17690. static UseSerializedUrlIfAny: boolean;
  17691. /**
  17692. * Define the url of the texture.
  17693. */
  17694. url: Nullable<string>;
  17695. /**
  17696. * Define an offset on the texture to offset the u coordinates of the UVs
  17697. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17698. */
  17699. uOffset: number;
  17700. /**
  17701. * Define an offset on the texture to offset the v coordinates of the UVs
  17702. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17703. */
  17704. vOffset: number;
  17705. /**
  17706. * Define an offset on the texture to scale the u coordinates of the UVs
  17707. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17708. */
  17709. uScale: number;
  17710. /**
  17711. * Define an offset on the texture to scale the v coordinates of the UVs
  17712. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17713. */
  17714. vScale: number;
  17715. /**
  17716. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17717. * @see http://doc.babylonjs.com/how_to/more_materials
  17718. */
  17719. uAng: number;
  17720. /**
  17721. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17722. * @see http://doc.babylonjs.com/how_to/more_materials
  17723. */
  17724. vAng: number;
  17725. /**
  17726. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17727. * @see http://doc.babylonjs.com/how_to/more_materials
  17728. */
  17729. wAng: number;
  17730. /**
  17731. * Defines the center of rotation (U)
  17732. */
  17733. uRotationCenter: number;
  17734. /**
  17735. * Defines the center of rotation (V)
  17736. */
  17737. vRotationCenter: number;
  17738. /**
  17739. * Defines the center of rotation (W)
  17740. */
  17741. wRotationCenter: number;
  17742. /**
  17743. * Are mip maps generated for this texture or not.
  17744. */
  17745. readonly noMipmap: boolean;
  17746. /**
  17747. * List of inspectable custom properties (used by the Inspector)
  17748. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  17749. */
  17750. inspectableCustomProperties: IInspectable[];
  17751. private _noMipmap;
  17752. /** @hidden */ invertY: boolean;
  17753. private _rowGenerationMatrix;
  17754. private _cachedTextureMatrix;
  17755. private _projectionModeMatrix;
  17756. private _t0;
  17757. private _t1;
  17758. private _t2;
  17759. private _cachedUOffset;
  17760. private _cachedVOffset;
  17761. private _cachedUScale;
  17762. private _cachedVScale;
  17763. private _cachedUAng;
  17764. private _cachedVAng;
  17765. private _cachedWAng;
  17766. private _cachedProjectionMatrixId;
  17767. private _cachedCoordinatesMode;
  17768. /** @hidden */
  17769. protected _initialSamplingMode: number;
  17770. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  17771. private _deleteBuffer;
  17772. protected _format: Nullable<number>;
  17773. private _delayedOnLoad;
  17774. private _delayedOnError;
  17775. /**
  17776. * Observable triggered once the texture has been loaded.
  17777. */
  17778. onLoadObservable: Observable<Texture>;
  17779. protected _isBlocking: boolean;
  17780. /**
  17781. * Is the texture preventing material to render while loading.
  17782. * If false, a default texture will be used instead of the loading one during the preparation step.
  17783. */
  17784. isBlocking: boolean;
  17785. /**
  17786. * Get the current sampling mode associated with the texture.
  17787. */
  17788. readonly samplingMode: number;
  17789. /**
  17790. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  17791. */
  17792. readonly invertY: boolean;
  17793. /**
  17794. * Instantiates a new texture.
  17795. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17796. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17797. * @param url define the url of the picture to load as a texture
  17798. * @param scene define the scene the texture will belong to
  17799. * @param noMipmap define if the texture will require mip maps or not
  17800. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17801. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17802. * @param onLoad define a callback triggered when the texture has been loaded
  17803. * @param onError define a callback triggered when an error occurred during the loading session
  17804. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17805. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17806. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17807. */
  17808. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  17809. /**
  17810. * Update the url (and optional buffer) of this texture if url was null during construction.
  17811. * @param url the url of the texture
  17812. * @param buffer the buffer of the texture (defaults to null)
  17813. * @param onLoad callback called when the texture is loaded (defaults to null)
  17814. */
  17815. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  17816. /**
  17817. * Finish the loading sequence of a texture flagged as delayed load.
  17818. * @hidden
  17819. */
  17820. delayLoad(): void;
  17821. private _prepareRowForTextureGeneration;
  17822. /**
  17823. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  17824. * @returns the transform matrix of the texture.
  17825. */
  17826. getTextureMatrix(): Matrix;
  17827. /**
  17828. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  17829. * @returns The reflection texture transform
  17830. */
  17831. getReflectionTextureMatrix(): Matrix;
  17832. /**
  17833. * Clones the texture.
  17834. * @returns the cloned texture
  17835. */
  17836. clone(): Texture;
  17837. /**
  17838. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17839. * @returns The JSON representation of the texture
  17840. */
  17841. serialize(): any;
  17842. /**
  17843. * Get the current class name of the texture useful for serialization or dynamic coding.
  17844. * @returns "Texture"
  17845. */
  17846. getClassName(): string;
  17847. /**
  17848. * Dispose the texture and release its associated resources.
  17849. */
  17850. dispose(): void;
  17851. /**
  17852. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  17853. * @param parsedTexture Define the JSON representation of the texture
  17854. * @param scene Define the scene the parsed texture should be instantiated in
  17855. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  17856. * @returns The parsed texture if successful
  17857. */
  17858. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  17859. /**
  17860. * Creates a texture from its base 64 representation.
  17861. * @param data Define the base64 payload without the data: prefix
  17862. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17863. * @param scene Define the scene the texture should belong to
  17864. * @param noMipmap Forces the texture to not create mip map information if true
  17865. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17866. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17867. * @param onLoad define a callback triggered when the texture has been loaded
  17868. * @param onError define a callback triggered when an error occurred during the loading session
  17869. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17870. * @returns the created texture
  17871. */
  17872. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  17873. /**
  17874. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  17875. * @param data Define the base64 payload without the data: prefix
  17876. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17877. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17878. * @param scene Define the scene the texture should belong to
  17879. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17880. * @param noMipmap Forces the texture to not create mip map information if true
  17881. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17882. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17883. * @param onLoad define a callback triggered when the texture has been loaded
  17884. * @param onError define a callback triggered when an error occurred during the loading session
  17885. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17886. * @returns the created texture
  17887. */
  17888. 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;
  17889. }
  17890. }
  17891. declare module BABYLON {
  17892. /**
  17893. * Raw texture can help creating a texture directly from an array of data.
  17894. * This can be super useful if you either get the data from an uncompressed source or
  17895. * if you wish to create your texture pixel by pixel.
  17896. */
  17897. export class RawTexture extends Texture {
  17898. /**
  17899. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  17900. */
  17901. format: number;
  17902. private _engine;
  17903. /**
  17904. * Instantiates a new RawTexture.
  17905. * Raw texture can help creating a texture directly from an array of data.
  17906. * This can be super useful if you either get the data from an uncompressed source or
  17907. * if you wish to create your texture pixel by pixel.
  17908. * @param data define the array of data to use to create the texture
  17909. * @param width define the width of the texture
  17910. * @param height define the height of the texture
  17911. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  17912. * @param scene define the scene the texture belongs to
  17913. * @param generateMipMaps define whether mip maps should be generated or not
  17914. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17915. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17916. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17917. */
  17918. constructor(data: ArrayBufferView, width: number, height: number,
  17919. /**
  17920. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  17921. */
  17922. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  17923. /**
  17924. * Updates the texture underlying data.
  17925. * @param data Define the new data of the texture
  17926. */
  17927. update(data: ArrayBufferView): void;
  17928. /**
  17929. * Creates a luminance texture from some data.
  17930. * @param data Define the texture data
  17931. * @param width Define the width of the texture
  17932. * @param height Define the height of the texture
  17933. * @param scene Define the scene the texture belongs to
  17934. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17935. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17936. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17937. * @returns the luminance texture
  17938. */
  17939. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  17940. /**
  17941. * Creates a luminance alpha texture from some data.
  17942. * @param data Define the texture data
  17943. * @param width Define the width of the texture
  17944. * @param height Define the height of the texture
  17945. * @param scene Define the scene the texture belongs to
  17946. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17947. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17948. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17949. * @returns the luminance alpha texture
  17950. */
  17951. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  17952. /**
  17953. * Creates an alpha texture from some data.
  17954. * @param data Define the texture data
  17955. * @param width Define the width of the texture
  17956. * @param height Define the height of the texture
  17957. * @param scene Define the scene the texture belongs to
  17958. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17959. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17960. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17961. * @returns the alpha texture
  17962. */
  17963. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  17964. /**
  17965. * Creates a RGB texture from some data.
  17966. * @param data Define the texture data
  17967. * @param width Define the width of the texture
  17968. * @param height Define the height of the texture
  17969. * @param scene Define the scene the texture belongs to
  17970. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17971. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17972. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17973. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17974. * @returns the RGB alpha texture
  17975. */
  17976. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  17977. /**
  17978. * Creates a RGBA texture from some data.
  17979. * @param data Define the texture data
  17980. * @param width Define the width of the texture
  17981. * @param height Define the height of the texture
  17982. * @param scene Define the scene the texture belongs to
  17983. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17984. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17985. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17986. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17987. * @returns the RGBA texture
  17988. */
  17989. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  17990. /**
  17991. * Creates a R texture from some data.
  17992. * @param data Define the texture data
  17993. * @param width Define the width of the texture
  17994. * @param height Define the height of the texture
  17995. * @param scene Define the scene the texture belongs to
  17996. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17997. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17998. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17999. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18000. * @returns the R texture
  18001. */
  18002. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18003. }
  18004. }
  18005. declare module BABYLON {
  18006. /**
  18007. * Defines a runtime animation
  18008. */
  18009. export class RuntimeAnimation {
  18010. private _events;
  18011. /**
  18012. * The current frame of the runtime animation
  18013. */
  18014. private _currentFrame;
  18015. /**
  18016. * The animation used by the runtime animation
  18017. */
  18018. private _animation;
  18019. /**
  18020. * The target of the runtime animation
  18021. */
  18022. private _target;
  18023. /**
  18024. * The initiating animatable
  18025. */
  18026. private _host;
  18027. /**
  18028. * The original value of the runtime animation
  18029. */
  18030. private _originalValue;
  18031. /**
  18032. * The original blend value of the runtime animation
  18033. */
  18034. private _originalBlendValue;
  18035. /**
  18036. * The offsets cache of the runtime animation
  18037. */
  18038. private _offsetsCache;
  18039. /**
  18040. * The high limits cache of the runtime animation
  18041. */
  18042. private _highLimitsCache;
  18043. /**
  18044. * Specifies if the runtime animation has been stopped
  18045. */
  18046. private _stopped;
  18047. /**
  18048. * The blending factor of the runtime animation
  18049. */
  18050. private _blendingFactor;
  18051. /**
  18052. * The BabylonJS scene
  18053. */
  18054. private _scene;
  18055. /**
  18056. * The current value of the runtime animation
  18057. */
  18058. private _currentValue;
  18059. /** @hidden */ workValue: any;
  18060. /**
  18061. * The active target of the runtime animation
  18062. */
  18063. private _activeTarget;
  18064. /**
  18065. * The target path of the runtime animation
  18066. */
  18067. private _targetPath;
  18068. /**
  18069. * The weight of the runtime animation
  18070. */
  18071. private _weight;
  18072. /**
  18073. * The ratio offset of the runtime animation
  18074. */
  18075. private _ratioOffset;
  18076. /**
  18077. * The previous delay of the runtime animation
  18078. */
  18079. private _previousDelay;
  18080. /**
  18081. * The previous ratio of the runtime animation
  18082. */
  18083. private _previousRatio;
  18084. /**
  18085. * Gets the current frame of the runtime animation
  18086. */
  18087. readonly currentFrame: number;
  18088. /**
  18089. * Gets the weight of the runtime animation
  18090. */
  18091. readonly weight: number;
  18092. /**
  18093. * Gets the current value of the runtime animation
  18094. */
  18095. readonly currentValue: any;
  18096. /**
  18097. * Gets the target path of the runtime animation
  18098. */
  18099. readonly targetPath: string;
  18100. /**
  18101. * Gets the actual target of the runtime animation
  18102. */
  18103. readonly target: any;
  18104. /**
  18105. * Create a new RuntimeAnimation object
  18106. * @param target defines the target of the animation
  18107. * @param animation defines the source animation object
  18108. * @param scene defines the hosting scene
  18109. * @param host defines the initiating Animatable
  18110. */
  18111. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18112. /**
  18113. * Gets the animation from the runtime animation
  18114. */
  18115. readonly animation: Animation;
  18116. /**
  18117. * Resets the runtime animation to the beginning
  18118. * @param restoreOriginal defines whether to restore the target property to the original value
  18119. */
  18120. reset(restoreOriginal?: boolean): void;
  18121. /**
  18122. * Specifies if the runtime animation is stopped
  18123. * @returns Boolean specifying if the runtime animation is stopped
  18124. */
  18125. isStopped(): boolean;
  18126. /**
  18127. * Disposes of the runtime animation
  18128. */
  18129. dispose(): void;
  18130. /**
  18131. * Interpolates the animation from the current frame
  18132. * @param currentFrame The frame to interpolate the animation to
  18133. * @param repeatCount The number of times that the animation should loop
  18134. * @param loopMode The type of looping mode to use
  18135. * @param offsetValue Animation offset value
  18136. * @param highLimitValue The high limit value
  18137. * @returns The interpolated value
  18138. */
  18139. private _interpolate;
  18140. /**
  18141. * Apply the interpolated value to the target
  18142. * @param currentValue defines the value computed by the animation
  18143. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18144. */
  18145. setValue(currentValue: any, weight?: number): void;
  18146. private _setValue;
  18147. /**
  18148. * Gets the loop pmode of the runtime animation
  18149. * @returns Loop Mode
  18150. */
  18151. private _getCorrectLoopMode;
  18152. /**
  18153. * Move the current animation to a given frame
  18154. * @param frame defines the frame to move to
  18155. */
  18156. goToFrame(frame: number): void;
  18157. /**
  18158. * @hidden Internal use only
  18159. */ prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18160. /**
  18161. * Execute the current animation
  18162. * @param delay defines the delay to add to the current frame
  18163. * @param from defines the lower bound of the animation range
  18164. * @param to defines the upper bound of the animation range
  18165. * @param loop defines if the current animation must loop
  18166. * @param speedRatio defines the current speed ratio
  18167. * @param weight defines the weight of the animation (default is -1 so no weight)
  18168. * @param onLoop optional callback called when animation loops
  18169. * @returns a boolean indicating if the animation is running
  18170. */
  18171. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18172. }
  18173. }
  18174. declare module BABYLON {
  18175. /**
  18176. * Class used to store an actual running animation
  18177. */
  18178. export class Animatable {
  18179. /** defines the target object */
  18180. target: any;
  18181. /** defines the starting frame number (default is 0) */
  18182. fromFrame: number;
  18183. /** defines the ending frame number (default is 100) */
  18184. toFrame: number;
  18185. /** defines if the animation must loop (default is false) */
  18186. loopAnimation: boolean;
  18187. /** defines a callback to call when animation ends if it is not looping */
  18188. onAnimationEnd?: (() => void) | null | undefined;
  18189. /** defines a callback to call when animation loops */
  18190. onAnimationLoop?: (() => void) | null | undefined;
  18191. private _localDelayOffset;
  18192. private _pausedDelay;
  18193. private _runtimeAnimations;
  18194. private _paused;
  18195. private _scene;
  18196. private _speedRatio;
  18197. private _weight;
  18198. private _syncRoot;
  18199. /**
  18200. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18201. * This will only apply for non looping animation (default is true)
  18202. */
  18203. disposeOnEnd: boolean;
  18204. /**
  18205. * Gets a boolean indicating if the animation has started
  18206. */
  18207. animationStarted: boolean;
  18208. /**
  18209. * Observer raised when the animation ends
  18210. */
  18211. onAnimationEndObservable: Observable<Animatable>;
  18212. /**
  18213. * Observer raised when the animation loops
  18214. */
  18215. onAnimationLoopObservable: Observable<Animatable>;
  18216. /**
  18217. * Gets the root Animatable used to synchronize and normalize animations
  18218. */
  18219. readonly syncRoot: Animatable;
  18220. /**
  18221. * Gets the current frame of the first RuntimeAnimation
  18222. * Used to synchronize Animatables
  18223. */
  18224. readonly masterFrame: number;
  18225. /**
  18226. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18227. */
  18228. weight: number;
  18229. /**
  18230. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18231. */
  18232. speedRatio: number;
  18233. /**
  18234. * Creates a new Animatable
  18235. * @param scene defines the hosting scene
  18236. * @param target defines the target object
  18237. * @param fromFrame defines the starting frame number (default is 0)
  18238. * @param toFrame defines the ending frame number (default is 100)
  18239. * @param loopAnimation defines if the animation must loop (default is false)
  18240. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18241. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18242. * @param animations defines a group of animation to add to the new Animatable
  18243. * @param onAnimationLoop defines a callback to call when animation loops
  18244. */
  18245. constructor(scene: Scene,
  18246. /** defines the target object */
  18247. target: any,
  18248. /** defines the starting frame number (default is 0) */
  18249. fromFrame?: number,
  18250. /** defines the ending frame number (default is 100) */
  18251. toFrame?: number,
  18252. /** defines if the animation must loop (default is false) */
  18253. loopAnimation?: boolean, speedRatio?: number,
  18254. /** defines a callback to call when animation ends if it is not looping */
  18255. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18256. /** defines a callback to call when animation loops */
  18257. onAnimationLoop?: (() => void) | null | undefined);
  18258. /**
  18259. * Synchronize and normalize current Animatable with a source Animatable
  18260. * This is useful when using animation weights and when animations are not of the same length
  18261. * @param root defines the root Animatable to synchronize with
  18262. * @returns the current Animatable
  18263. */
  18264. syncWith(root: Animatable): Animatable;
  18265. /**
  18266. * Gets the list of runtime animations
  18267. * @returns an array of RuntimeAnimation
  18268. */
  18269. getAnimations(): RuntimeAnimation[];
  18270. /**
  18271. * Adds more animations to the current animatable
  18272. * @param target defines the target of the animations
  18273. * @param animations defines the new animations to add
  18274. */
  18275. appendAnimations(target: any, animations: Animation[]): void;
  18276. /**
  18277. * Gets the source animation for a specific property
  18278. * @param property defines the propertyu to look for
  18279. * @returns null or the source animation for the given property
  18280. */
  18281. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18282. /**
  18283. * Gets the runtime animation for a specific property
  18284. * @param property defines the propertyu to look for
  18285. * @returns null or the runtime animation for the given property
  18286. */
  18287. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18288. /**
  18289. * Resets the animatable to its original state
  18290. */
  18291. reset(): void;
  18292. /**
  18293. * Allows the animatable to blend with current running animations
  18294. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18295. * @param blendingSpeed defines the blending speed to use
  18296. */
  18297. enableBlending(blendingSpeed: number): void;
  18298. /**
  18299. * Disable animation blending
  18300. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18301. */
  18302. disableBlending(): void;
  18303. /**
  18304. * Jump directly to a given frame
  18305. * @param frame defines the frame to jump to
  18306. */
  18307. goToFrame(frame: number): void;
  18308. /**
  18309. * Pause the animation
  18310. */
  18311. pause(): void;
  18312. /**
  18313. * Restart the animation
  18314. */
  18315. restart(): void;
  18316. private _raiseOnAnimationEnd;
  18317. /**
  18318. * Stop and delete the current animation
  18319. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18320. * @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)
  18321. */
  18322. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18323. /**
  18324. * Wait asynchronously for the animation to end
  18325. * @returns a promise which will be fullfilled when the animation ends
  18326. */
  18327. waitAsync(): Promise<Animatable>;
  18328. /** @hidden */ animate(delay: number): boolean;
  18329. }
  18330. interface Scene {
  18331. /** @hidden */ registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18332. /** @hidden */ processLateAnimationBindingsForMatrices(holder: {
  18333. totalWeight: number;
  18334. animations: RuntimeAnimation[];
  18335. originalValue: Matrix;
  18336. }): any;
  18337. /** @hidden */ processLateAnimationBindingsForQuaternions(holder: {
  18338. totalWeight: number;
  18339. animations: RuntimeAnimation[];
  18340. originalValue: Quaternion;
  18341. }, refQuaternion: Quaternion): Quaternion;
  18342. /** @hidden */ processLateAnimationBindings(): void;
  18343. /**
  18344. * Will start the animation sequence of a given target
  18345. * @param target defines the target
  18346. * @param from defines from which frame should animation start
  18347. * @param to defines until which frame should animation run.
  18348. * @param weight defines the weight to apply to the animation (1.0 by default)
  18349. * @param loop defines if the animation loops
  18350. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18351. * @param onAnimationEnd defines the function to be executed when the animation ends
  18352. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18353. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18354. * @param onAnimationLoop defines the callback to call when an animation loops
  18355. * @returns the animatable object created for this animation
  18356. */
  18357. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18358. /**
  18359. * Will start the animation sequence of a given target
  18360. * @param target defines the target
  18361. * @param from defines from which frame should animation start
  18362. * @param to defines until which frame should animation run.
  18363. * @param loop defines if the animation loops
  18364. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18365. * @param onAnimationEnd defines the function to be executed when the animation ends
  18366. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18367. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18368. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18369. * @param onAnimationLoop defines the callback to call when an animation loops
  18370. * @returns the animatable object created for this animation
  18371. */
  18372. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18373. /**
  18374. * Will start the animation sequence of a given target and its hierarchy
  18375. * @param target defines the target
  18376. * @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.
  18377. * @param from defines from which frame should animation start
  18378. * @param to defines until which frame should animation run.
  18379. * @param loop defines if the animation loops
  18380. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18381. * @param onAnimationEnd defines the function to be executed when the animation ends
  18382. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18383. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18384. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18385. * @param onAnimationLoop defines the callback to call when an animation loops
  18386. * @returns the list of created animatables
  18387. */
  18388. 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[];
  18389. /**
  18390. * Begin a new animation on a given node
  18391. * @param target defines the target where the animation will take place
  18392. * @param animations defines the list of animations to start
  18393. * @param from defines the initial value
  18394. * @param to defines the final value
  18395. * @param loop defines if you want animation to loop (off by default)
  18396. * @param speedRatio defines the speed ratio to apply to all animations
  18397. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18398. * @param onAnimationLoop defines the callback to call when an animation loops
  18399. * @returns the list of created animatables
  18400. */
  18401. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18402. /**
  18403. * Begin a new animation on a given node and its hierarchy
  18404. * @param target defines the root node where the animation will take place
  18405. * @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.
  18406. * @param animations defines the list of animations to start
  18407. * @param from defines the initial value
  18408. * @param to defines the final value
  18409. * @param loop defines if you want animation to loop (off by default)
  18410. * @param speedRatio defines the speed ratio to apply to all animations
  18411. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18412. * @param onAnimationLoop defines the callback to call when an animation loops
  18413. * @returns the list of animatables created for all nodes
  18414. */
  18415. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18416. /**
  18417. * Gets the animatable associated with a specific target
  18418. * @param target defines the target of the animatable
  18419. * @returns the required animatable if found
  18420. */
  18421. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18422. /**
  18423. * Gets all animatables associated with a given target
  18424. * @param target defines the target to look animatables for
  18425. * @returns an array of Animatables
  18426. */
  18427. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18428. /**
  18429. * Will stop the animation of the given target
  18430. * @param target - the target
  18431. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18432. * @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)
  18433. */
  18434. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18435. /**
  18436. * Stops and removes all animations that have been applied to the scene
  18437. */
  18438. stopAllAnimations(): void;
  18439. }
  18440. interface Bone {
  18441. /**
  18442. * Copy an animation range from another bone
  18443. * @param source defines the source bone
  18444. * @param rangeName defines the range name to copy
  18445. * @param frameOffset defines the frame offset
  18446. * @param rescaleAsRequired defines if rescaling must be applied if required
  18447. * @param skelDimensionsRatio defines the scaling ratio
  18448. * @returns true if operation was successful
  18449. */
  18450. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18451. }
  18452. }
  18453. declare module BABYLON {
  18454. /**
  18455. * Class used to handle skinning animations
  18456. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18457. */
  18458. export class Skeleton implements IAnimatable {
  18459. /** defines the skeleton name */
  18460. name: string;
  18461. /** defines the skeleton Id */
  18462. id: string;
  18463. /**
  18464. * Defines the list of child bones
  18465. */
  18466. bones: Bone[];
  18467. /**
  18468. * Defines an estimate of the dimension of the skeleton at rest
  18469. */
  18470. dimensionsAtRest: Vector3;
  18471. /**
  18472. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18473. */
  18474. needInitialSkinMatrix: boolean;
  18475. /**
  18476. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18477. */
  18478. overrideMesh: Nullable<AbstractMesh>;
  18479. /**
  18480. * Gets the list of animations attached to this skeleton
  18481. */
  18482. animations: Array<Animation>;
  18483. private _scene;
  18484. private _isDirty;
  18485. private _transformMatrices;
  18486. private _transformMatrixTexture;
  18487. private _meshesWithPoseMatrix;
  18488. private _animatables;
  18489. private _identity;
  18490. private _synchronizedWithMesh;
  18491. private _ranges;
  18492. private _lastAbsoluteTransformsUpdateId;
  18493. private _canUseTextureForBones;
  18494. private _uniqueId;
  18495. /** @hidden */ numBonesWithLinkedTransformNode: number;
  18496. /**
  18497. * Specifies if the skeleton should be serialized
  18498. */
  18499. doNotSerialize: boolean;
  18500. private _useTextureToStoreBoneMatrices;
  18501. /**
  18502. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18503. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18504. */
  18505. useTextureToStoreBoneMatrices: boolean;
  18506. private _animationPropertiesOverride;
  18507. /**
  18508. * Gets or sets the animation properties override
  18509. */
  18510. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18511. /**
  18512. * List of inspectable custom properties (used by the Inspector)
  18513. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18514. */
  18515. inspectableCustomProperties: IInspectable[];
  18516. /**
  18517. * An observable triggered before computing the skeleton's matrices
  18518. */
  18519. onBeforeComputeObservable: Observable<Skeleton>;
  18520. /**
  18521. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18522. */
  18523. readonly isUsingTextureForMatrices: boolean;
  18524. /**
  18525. * Gets the unique ID of this skeleton
  18526. */
  18527. readonly uniqueId: number;
  18528. /**
  18529. * Creates a new skeleton
  18530. * @param name defines the skeleton name
  18531. * @param id defines the skeleton Id
  18532. * @param scene defines the hosting scene
  18533. */
  18534. constructor(
  18535. /** defines the skeleton name */
  18536. name: string,
  18537. /** defines the skeleton Id */
  18538. id: string, scene: Scene);
  18539. /**
  18540. * Gets the current object class name.
  18541. * @return the class name
  18542. */
  18543. getClassName(): string;
  18544. /**
  18545. * Returns an array containing the root bones
  18546. * @returns an array containing the root bones
  18547. */
  18548. getChildren(): Array<Bone>;
  18549. /**
  18550. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18551. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18552. * @returns a Float32Array containing matrices data
  18553. */
  18554. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18555. /**
  18556. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18557. * @returns a raw texture containing the data
  18558. */
  18559. getTransformMatrixTexture(): Nullable<RawTexture>;
  18560. /**
  18561. * Gets the current hosting scene
  18562. * @returns a scene object
  18563. */
  18564. getScene(): Scene;
  18565. /**
  18566. * Gets a string representing the current skeleton data
  18567. * @param fullDetails defines a boolean indicating if we want a verbose version
  18568. * @returns a string representing the current skeleton data
  18569. */
  18570. toString(fullDetails?: boolean): string;
  18571. /**
  18572. * Get bone's index searching by name
  18573. * @param name defines bone's name to search for
  18574. * @return the indice of the bone. Returns -1 if not found
  18575. */
  18576. getBoneIndexByName(name: string): number;
  18577. /**
  18578. * Creater a new animation range
  18579. * @param name defines the name of the range
  18580. * @param from defines the start key
  18581. * @param to defines the end key
  18582. */
  18583. createAnimationRange(name: string, from: number, to: number): void;
  18584. /**
  18585. * Delete a specific animation range
  18586. * @param name defines the name of the range
  18587. * @param deleteFrames defines if frames must be removed as well
  18588. */
  18589. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18590. /**
  18591. * Gets a specific animation range
  18592. * @param name defines the name of the range to look for
  18593. * @returns the requested animation range or null if not found
  18594. */
  18595. getAnimationRange(name: string): Nullable<AnimationRange>;
  18596. /**
  18597. * Gets the list of all animation ranges defined on this skeleton
  18598. * @returns an array
  18599. */
  18600. getAnimationRanges(): Nullable<AnimationRange>[];
  18601. /**
  18602. * Copy animation range from a source skeleton.
  18603. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18604. * @param source defines the source skeleton
  18605. * @param name defines the name of the range to copy
  18606. * @param rescaleAsRequired defines if rescaling must be applied if required
  18607. * @returns true if operation was successful
  18608. */
  18609. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18610. /**
  18611. * Forces the skeleton to go to rest pose
  18612. */
  18613. returnToRest(): void;
  18614. private _getHighestAnimationFrame;
  18615. /**
  18616. * Begin a specific animation range
  18617. * @param name defines the name of the range to start
  18618. * @param loop defines if looping must be turned on (false by default)
  18619. * @param speedRatio defines the speed ratio to apply (1 by default)
  18620. * @param onAnimationEnd defines a callback which will be called when animation will end
  18621. * @returns a new animatable
  18622. */
  18623. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  18624. /** @hidden */ markAsDirty(): void;
  18625. /** @hidden */ registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18626. /** @hidden */ unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18627. private _computeTransformMatrices;
  18628. /**
  18629. * Build all resources required to render a skeleton
  18630. */
  18631. prepare(): void;
  18632. /**
  18633. * Gets the list of animatables currently running for this skeleton
  18634. * @returns an array of animatables
  18635. */
  18636. getAnimatables(): IAnimatable[];
  18637. /**
  18638. * Clone the current skeleton
  18639. * @param name defines the name of the new skeleton
  18640. * @param id defines the id of the enw skeleton
  18641. * @returns the new skeleton
  18642. */
  18643. clone(name: string, id: string): Skeleton;
  18644. /**
  18645. * Enable animation blending for this skeleton
  18646. * @param blendingSpeed defines the blending speed to apply
  18647. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18648. */
  18649. enableBlending(blendingSpeed?: number): void;
  18650. /**
  18651. * Releases all resources associated with the current skeleton
  18652. */
  18653. dispose(): void;
  18654. /**
  18655. * Serialize the skeleton in a JSON object
  18656. * @returns a JSON object
  18657. */
  18658. serialize(): any;
  18659. /**
  18660. * Creates a new skeleton from serialized data
  18661. * @param parsedSkeleton defines the serialized data
  18662. * @param scene defines the hosting scene
  18663. * @returns a new skeleton
  18664. */
  18665. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  18666. /**
  18667. * Compute all node absolute transforms
  18668. * @param forceUpdate defines if computation must be done even if cache is up to date
  18669. */
  18670. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  18671. /**
  18672. * Gets the root pose matrix
  18673. * @returns a matrix
  18674. */
  18675. getPoseMatrix(): Nullable<Matrix>;
  18676. /**
  18677. * Sorts bones per internal index
  18678. */
  18679. sortBones(): void;
  18680. private _sortBones;
  18681. }
  18682. }
  18683. declare module BABYLON {
  18684. /**
  18685. * Defines a target to use with MorphTargetManager
  18686. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18687. */
  18688. export class MorphTarget implements IAnimatable {
  18689. /** defines the name of the target */
  18690. name: string;
  18691. /**
  18692. * Gets or sets the list of animations
  18693. */
  18694. animations: Animation[];
  18695. private _scene;
  18696. private _positions;
  18697. private _normals;
  18698. private _tangents;
  18699. private _influence;
  18700. /**
  18701. * Observable raised when the influence changes
  18702. */
  18703. onInfluenceChanged: Observable<boolean>;
  18704. /** @hidden */ onDataLayoutChanged: Observable<void>;
  18705. /**
  18706. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18707. */
  18708. influence: number;
  18709. /**
  18710. * Gets or sets the id of the morph Target
  18711. */
  18712. id: string;
  18713. private _animationPropertiesOverride;
  18714. /**
  18715. * Gets or sets the animation properties override
  18716. */
  18717. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18718. /**
  18719. * Creates a new MorphTarget
  18720. * @param name defines the name of the target
  18721. * @param influence defines the influence to use
  18722. * @param scene defines the scene the morphtarget belongs to
  18723. */
  18724. constructor(
  18725. /** defines the name of the target */
  18726. name: string, influence?: number, scene?: Nullable<Scene>);
  18727. /**
  18728. * Gets a boolean defining if the target contains position data
  18729. */
  18730. readonly hasPositions: boolean;
  18731. /**
  18732. * Gets a boolean defining if the target contains normal data
  18733. */
  18734. readonly hasNormals: boolean;
  18735. /**
  18736. * Gets a boolean defining if the target contains tangent data
  18737. */
  18738. readonly hasTangents: boolean;
  18739. /**
  18740. * Affects position data to this target
  18741. * @param data defines the position data to use
  18742. */
  18743. setPositions(data: Nullable<FloatArray>): void;
  18744. /**
  18745. * Gets the position data stored in this target
  18746. * @returns a FloatArray containing the position data (or null if not present)
  18747. */
  18748. getPositions(): Nullable<FloatArray>;
  18749. /**
  18750. * Affects normal data to this target
  18751. * @param data defines the normal data to use
  18752. */
  18753. setNormals(data: Nullable<FloatArray>): void;
  18754. /**
  18755. * Gets the normal data stored in this target
  18756. * @returns a FloatArray containing the normal data (or null if not present)
  18757. */
  18758. getNormals(): Nullable<FloatArray>;
  18759. /**
  18760. * Affects tangent data to this target
  18761. * @param data defines the tangent data to use
  18762. */
  18763. setTangents(data: Nullable<FloatArray>): void;
  18764. /**
  18765. * Gets the tangent data stored in this target
  18766. * @returns a FloatArray containing the tangent data (or null if not present)
  18767. */
  18768. getTangents(): Nullable<FloatArray>;
  18769. /**
  18770. * Serializes the current target into a Serialization object
  18771. * @returns the serialized object
  18772. */
  18773. serialize(): any;
  18774. /**
  18775. * Returns the string "MorphTarget"
  18776. * @returns "MorphTarget"
  18777. */
  18778. getClassName(): string;
  18779. /**
  18780. * Creates a new target from serialized data
  18781. * @param serializationObject defines the serialized data to use
  18782. * @returns a new MorphTarget
  18783. */
  18784. static Parse(serializationObject: any): MorphTarget;
  18785. /**
  18786. * Creates a MorphTarget from mesh data
  18787. * @param mesh defines the source mesh
  18788. * @param name defines the name to use for the new target
  18789. * @param influence defines the influence to attach to the target
  18790. * @returns a new MorphTarget
  18791. */
  18792. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  18793. }
  18794. }
  18795. declare module BABYLON {
  18796. /**
  18797. * This class is used to deform meshes using morphing between different targets
  18798. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18799. */
  18800. export class MorphTargetManager {
  18801. private _targets;
  18802. private _targetInfluenceChangedObservers;
  18803. private _targetDataLayoutChangedObservers;
  18804. private _activeTargets;
  18805. private _scene;
  18806. private _influences;
  18807. private _supportsNormals;
  18808. private _supportsTangents;
  18809. private _vertexCount;
  18810. private _uniqueId;
  18811. private _tempInfluences;
  18812. /**
  18813. * Creates a new MorphTargetManager
  18814. * @param scene defines the current scene
  18815. */
  18816. constructor(scene?: Nullable<Scene>);
  18817. /**
  18818. * Gets the unique ID of this manager
  18819. */
  18820. readonly uniqueId: number;
  18821. /**
  18822. * Gets the number of vertices handled by this manager
  18823. */
  18824. readonly vertexCount: number;
  18825. /**
  18826. * Gets a boolean indicating if this manager supports morphing of normals
  18827. */
  18828. readonly supportsNormals: boolean;
  18829. /**
  18830. * Gets a boolean indicating if this manager supports morphing of tangents
  18831. */
  18832. readonly supportsTangents: boolean;
  18833. /**
  18834. * Gets the number of targets stored in this manager
  18835. */
  18836. readonly numTargets: number;
  18837. /**
  18838. * Gets the number of influencers (ie. the number of targets with influences > 0)
  18839. */
  18840. readonly numInfluencers: number;
  18841. /**
  18842. * Gets the list of influences (one per target)
  18843. */
  18844. readonly influences: Float32Array;
  18845. /**
  18846. * Gets the active target at specified index. An active target is a target with an influence > 0
  18847. * @param index defines the index to check
  18848. * @returns the requested target
  18849. */
  18850. getActiveTarget(index: number): MorphTarget;
  18851. /**
  18852. * Gets the target at specified index
  18853. * @param index defines the index to check
  18854. * @returns the requested target
  18855. */
  18856. getTarget(index: number): MorphTarget;
  18857. /**
  18858. * Add a new target to this manager
  18859. * @param target defines the target to add
  18860. */
  18861. addTarget(target: MorphTarget): void;
  18862. /**
  18863. * Removes a target from the manager
  18864. * @param target defines the target to remove
  18865. */
  18866. removeTarget(target: MorphTarget): void;
  18867. /**
  18868. * Serializes the current manager into a Serialization object
  18869. * @returns the serialized object
  18870. */
  18871. serialize(): any;
  18872. private _syncActiveTargets;
  18873. /**
  18874. * Syncrhonize the targets with all the meshes using this morph target manager
  18875. */
  18876. synchronize(): void;
  18877. /**
  18878. * Creates a new MorphTargetManager from serialized data
  18879. * @param serializationObject defines the serialized data
  18880. * @param scene defines the hosting scene
  18881. * @returns the new MorphTargetManager
  18882. */
  18883. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  18884. }
  18885. }
  18886. declare module BABYLON {
  18887. /**
  18888. * Mesh representing the gorund
  18889. */
  18890. export class GroundMesh extends Mesh {
  18891. /** If octree should be generated */
  18892. generateOctree: boolean;
  18893. private _heightQuads;
  18894. /** @hidden */ subdivisionsX: number;
  18895. /** @hidden */ subdivisionsY: number;
  18896. /** @hidden */ width: number;
  18897. /** @hidden */ height: number;
  18898. /** @hidden */ minX: number;
  18899. /** @hidden */ maxX: number;
  18900. /** @hidden */ minZ: number;
  18901. /** @hidden */ maxZ: number;
  18902. constructor(name: string, scene: Scene);
  18903. /**
  18904. * "GroundMesh"
  18905. * @returns "GroundMesh"
  18906. */
  18907. getClassName(): string;
  18908. /**
  18909. * The minimum of x and y subdivisions
  18910. */
  18911. readonly subdivisions: number;
  18912. /**
  18913. * X subdivisions
  18914. */
  18915. readonly subdivisionsX: number;
  18916. /**
  18917. * Y subdivisions
  18918. */
  18919. readonly subdivisionsY: number;
  18920. /**
  18921. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  18922. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18923. * @param chunksCount the number of subdivisions for x and y
  18924. * @param octreeBlocksSize (Default: 32)
  18925. */
  18926. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  18927. /**
  18928. * Returns a height (y) value in the Worl system :
  18929. * the ground altitude at the coordinates (x, z) expressed in the World system.
  18930. * @param x x coordinate
  18931. * @param z z coordinate
  18932. * @returns the ground y position if (x, z) are outside the ground surface.
  18933. */
  18934. getHeightAtCoordinates(x: number, z: number): number;
  18935. /**
  18936. * Returns a normalized vector (Vector3) orthogonal to the ground
  18937. * at the ground coordinates (x, z) expressed in the World system.
  18938. * @param x x coordinate
  18939. * @param z z coordinate
  18940. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  18941. */
  18942. getNormalAtCoordinates(x: number, z: number): Vector3;
  18943. /**
  18944. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  18945. * at the ground coordinates (x, z) expressed in the World system.
  18946. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  18947. * @param x x coordinate
  18948. * @param z z coordinate
  18949. * @param ref vector to store the result
  18950. * @returns the GroundMesh.
  18951. */
  18952. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  18953. /**
  18954. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  18955. * if the ground has been updated.
  18956. * This can be used in the render loop.
  18957. * @returns the GroundMesh.
  18958. */
  18959. updateCoordinateHeights(): GroundMesh;
  18960. private _getFacetAt;
  18961. private _initHeightQuads;
  18962. private _computeHeightQuads;
  18963. /**
  18964. * Serializes this ground mesh
  18965. * @param serializationObject object to write serialization to
  18966. */
  18967. serialize(serializationObject: any): void;
  18968. /**
  18969. * Parses a serialized ground mesh
  18970. * @param parsedMesh the serialized mesh
  18971. * @param scene the scene to create the ground mesh in
  18972. * @returns the created ground mesh
  18973. */
  18974. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  18975. }
  18976. }
  18977. declare module BABYLON {
  18978. /**
  18979. * Interface for Physics-Joint data
  18980. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18981. */
  18982. export interface PhysicsJointData {
  18983. /**
  18984. * The main pivot of the joint
  18985. */
  18986. mainPivot?: Vector3;
  18987. /**
  18988. * The connected pivot of the joint
  18989. */
  18990. connectedPivot?: Vector3;
  18991. /**
  18992. * The main axis of the joint
  18993. */
  18994. mainAxis?: Vector3;
  18995. /**
  18996. * The connected axis of the joint
  18997. */
  18998. connectedAxis?: Vector3;
  18999. /**
  19000. * The collision of the joint
  19001. */
  19002. collision?: boolean;
  19003. /**
  19004. * Native Oimo/Cannon/Energy data
  19005. */
  19006. nativeParams?: any;
  19007. }
  19008. /**
  19009. * This is a holder class for the physics joint created by the physics plugin
  19010. * It holds a set of functions to control the underlying joint
  19011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19012. */
  19013. export class PhysicsJoint {
  19014. /**
  19015. * The type of the physics joint
  19016. */
  19017. type: number;
  19018. /**
  19019. * The data for the physics joint
  19020. */
  19021. jointData: PhysicsJointData;
  19022. private _physicsJoint;
  19023. protected _physicsPlugin: IPhysicsEnginePlugin;
  19024. /**
  19025. * Initializes the physics joint
  19026. * @param type The type of the physics joint
  19027. * @param jointData The data for the physics joint
  19028. */
  19029. constructor(
  19030. /**
  19031. * The type of the physics joint
  19032. */
  19033. type: number,
  19034. /**
  19035. * The data for the physics joint
  19036. */
  19037. jointData: PhysicsJointData);
  19038. /**
  19039. * Gets the physics joint
  19040. */
  19041. /**
  19042. * Sets the physics joint
  19043. */
  19044. physicsJoint: any;
  19045. /**
  19046. * Sets the physics plugin
  19047. */
  19048. physicsPlugin: IPhysicsEnginePlugin;
  19049. /**
  19050. * Execute a function that is physics-plugin specific.
  19051. * @param {Function} func the function that will be executed.
  19052. * It accepts two parameters: the physics world and the physics joint
  19053. */
  19054. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19055. /**
  19056. * Distance-Joint type
  19057. */
  19058. static DistanceJoint: number;
  19059. /**
  19060. * Hinge-Joint type
  19061. */
  19062. static HingeJoint: number;
  19063. /**
  19064. * Ball-and-Socket joint type
  19065. */
  19066. static BallAndSocketJoint: number;
  19067. /**
  19068. * Wheel-Joint type
  19069. */
  19070. static WheelJoint: number;
  19071. /**
  19072. * Slider-Joint type
  19073. */
  19074. static SliderJoint: number;
  19075. /**
  19076. * Prismatic-Joint type
  19077. */
  19078. static PrismaticJoint: number;
  19079. /**
  19080. * Universal-Joint type
  19081. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19082. */
  19083. static UniversalJoint: number;
  19084. /**
  19085. * Hinge-Joint 2 type
  19086. */
  19087. static Hinge2Joint: number;
  19088. /**
  19089. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19090. */
  19091. static PointToPointJoint: number;
  19092. /**
  19093. * Spring-Joint type
  19094. */
  19095. static SpringJoint: number;
  19096. /**
  19097. * Lock-Joint type
  19098. */
  19099. static LockJoint: number;
  19100. }
  19101. /**
  19102. * A class representing a physics distance joint
  19103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19104. */
  19105. export class DistanceJoint extends PhysicsJoint {
  19106. /**
  19107. *
  19108. * @param jointData The data for the Distance-Joint
  19109. */
  19110. constructor(jointData: DistanceJointData);
  19111. /**
  19112. * Update the predefined distance.
  19113. * @param maxDistance The maximum preferred distance
  19114. * @param minDistance The minimum preferred distance
  19115. */
  19116. updateDistance(maxDistance: number, minDistance?: number): void;
  19117. }
  19118. /**
  19119. * Represents a Motor-Enabled Joint
  19120. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19121. */
  19122. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19123. /**
  19124. * Initializes the Motor-Enabled Joint
  19125. * @param type The type of the joint
  19126. * @param jointData The physica joint data for the joint
  19127. */
  19128. constructor(type: number, jointData: PhysicsJointData);
  19129. /**
  19130. * Set the motor values.
  19131. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19132. * @param force the force to apply
  19133. * @param maxForce max force for this motor.
  19134. */
  19135. setMotor(force?: number, maxForce?: number): void;
  19136. /**
  19137. * Set the motor's limits.
  19138. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19139. * @param upperLimit The upper limit of the motor
  19140. * @param lowerLimit The lower limit of the motor
  19141. */
  19142. setLimit(upperLimit: number, lowerLimit?: number): void;
  19143. }
  19144. /**
  19145. * This class represents a single physics Hinge-Joint
  19146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19147. */
  19148. export class HingeJoint extends MotorEnabledJoint {
  19149. /**
  19150. * Initializes the Hinge-Joint
  19151. * @param jointData The joint data for the Hinge-Joint
  19152. */
  19153. constructor(jointData: PhysicsJointData);
  19154. /**
  19155. * Set the motor values.
  19156. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19157. * @param {number} force the force to apply
  19158. * @param {number} maxForce max force for this motor.
  19159. */
  19160. setMotor(force?: number, maxForce?: number): void;
  19161. /**
  19162. * Set the motor's limits.
  19163. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19164. * @param upperLimit The upper limit of the motor
  19165. * @param lowerLimit The lower limit of the motor
  19166. */
  19167. setLimit(upperLimit: number, lowerLimit?: number): void;
  19168. }
  19169. /**
  19170. * This class represents a dual hinge physics joint (same as wheel joint)
  19171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19172. */
  19173. export class Hinge2Joint extends MotorEnabledJoint {
  19174. /**
  19175. * Initializes the Hinge2-Joint
  19176. * @param jointData The joint data for the Hinge2-Joint
  19177. */
  19178. constructor(jointData: PhysicsJointData);
  19179. /**
  19180. * Set the motor values.
  19181. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19182. * @param {number} targetSpeed the speed the motor is to reach
  19183. * @param {number} maxForce max force for this motor.
  19184. * @param {motorIndex} the motor's index, 0 or 1.
  19185. */
  19186. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19187. /**
  19188. * Set the motor limits.
  19189. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19190. * @param {number} upperLimit the upper limit
  19191. * @param {number} lowerLimit lower limit
  19192. * @param {motorIndex} the motor's index, 0 or 1.
  19193. */
  19194. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19195. }
  19196. /**
  19197. * Interface for a motor enabled joint
  19198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19199. */
  19200. export interface IMotorEnabledJoint {
  19201. /**
  19202. * Physics joint
  19203. */
  19204. physicsJoint: any;
  19205. /**
  19206. * Sets the motor of the motor-enabled joint
  19207. * @param force The force of the motor
  19208. * @param maxForce The maximum force of the motor
  19209. * @param motorIndex The index of the motor
  19210. */
  19211. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19212. /**
  19213. * Sets the limit of the motor
  19214. * @param upperLimit The upper limit of the motor
  19215. * @param lowerLimit The lower limit of the motor
  19216. * @param motorIndex The index of the motor
  19217. */
  19218. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19219. }
  19220. /**
  19221. * Joint data for a Distance-Joint
  19222. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19223. */
  19224. export interface DistanceJointData extends PhysicsJointData {
  19225. /**
  19226. * Max distance the 2 joint objects can be apart
  19227. */
  19228. maxDistance: number;
  19229. }
  19230. /**
  19231. * Joint data from a spring joint
  19232. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19233. */
  19234. export interface SpringJointData extends PhysicsJointData {
  19235. /**
  19236. * Length of the spring
  19237. */
  19238. length: number;
  19239. /**
  19240. * Stiffness of the spring
  19241. */
  19242. stiffness: number;
  19243. /**
  19244. * Damping of the spring
  19245. */
  19246. damping: number;
  19247. /** this callback will be called when applying the force to the impostors. */
  19248. forceApplicationCallback: () => void;
  19249. }
  19250. }
  19251. declare module BABYLON {
  19252. /**
  19253. * Holds the data for the raycast result
  19254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19255. */
  19256. export class PhysicsRaycastResult {
  19257. private _hasHit;
  19258. private _hitDistance;
  19259. private _hitNormalWorld;
  19260. private _hitPointWorld;
  19261. private _rayFromWorld;
  19262. private _rayToWorld;
  19263. /**
  19264. * Gets if there was a hit
  19265. */
  19266. readonly hasHit: boolean;
  19267. /**
  19268. * Gets the distance from the hit
  19269. */
  19270. readonly hitDistance: number;
  19271. /**
  19272. * Gets the hit normal/direction in the world
  19273. */
  19274. readonly hitNormalWorld: Vector3;
  19275. /**
  19276. * Gets the hit point in the world
  19277. */
  19278. readonly hitPointWorld: Vector3;
  19279. /**
  19280. * Gets the ray "start point" of the ray in the world
  19281. */
  19282. readonly rayFromWorld: Vector3;
  19283. /**
  19284. * Gets the ray "end point" of the ray in the world
  19285. */
  19286. readonly rayToWorld: Vector3;
  19287. /**
  19288. * Sets the hit data (normal & point in world space)
  19289. * @param hitNormalWorld defines the normal in world space
  19290. * @param hitPointWorld defines the point in world space
  19291. */
  19292. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19293. /**
  19294. * Sets the distance from the start point to the hit point
  19295. * @param distance
  19296. */
  19297. setHitDistance(distance: number): void;
  19298. /**
  19299. * Calculates the distance manually
  19300. */
  19301. calculateHitDistance(): void;
  19302. /**
  19303. * Resets all the values to default
  19304. * @param from The from point on world space
  19305. * @param to The to point on world space
  19306. */
  19307. reset(from?: Vector3, to?: Vector3): void;
  19308. }
  19309. /**
  19310. * Interface for the size containing width and height
  19311. */
  19312. interface IXYZ {
  19313. /**
  19314. * X
  19315. */
  19316. x: number;
  19317. /**
  19318. * Y
  19319. */
  19320. y: number;
  19321. /**
  19322. * Z
  19323. */
  19324. z: number;
  19325. }
  19326. }
  19327. declare module BABYLON {
  19328. /**
  19329. * Interface used to describe a physics joint
  19330. */
  19331. export interface PhysicsImpostorJoint {
  19332. /** Defines the main impostor to which the joint is linked */
  19333. mainImpostor: PhysicsImpostor;
  19334. /** Defines the impostor that is connected to the main impostor using this joint */
  19335. connectedImpostor: PhysicsImpostor;
  19336. /** Defines the joint itself */
  19337. joint: PhysicsJoint;
  19338. }
  19339. /** @hidden */
  19340. export interface IPhysicsEnginePlugin {
  19341. world: any;
  19342. name: string;
  19343. setGravity(gravity: Vector3): void;
  19344. setTimeStep(timeStep: number): void;
  19345. getTimeStep(): number;
  19346. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19347. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19348. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19349. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19350. removePhysicsBody(impostor: PhysicsImpostor): void;
  19351. generateJoint(joint: PhysicsImpostorJoint): void;
  19352. removeJoint(joint: PhysicsImpostorJoint): void;
  19353. isSupported(): boolean;
  19354. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19355. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19356. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19357. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19358. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19359. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19360. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19361. getBodyMass(impostor: PhysicsImpostor): number;
  19362. getBodyFriction(impostor: PhysicsImpostor): number;
  19363. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19364. getBodyRestitution(impostor: PhysicsImpostor): number;
  19365. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19366. getBodyPressure?(impostor: PhysicsImpostor): number;
  19367. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19368. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19369. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19370. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19371. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19372. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19373. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19374. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19375. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19376. sleepBody(impostor: PhysicsImpostor): void;
  19377. wakeUpBody(impostor: PhysicsImpostor): void;
  19378. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19379. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19380. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19381. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19382. getRadius(impostor: PhysicsImpostor): number;
  19383. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19384. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19385. dispose(): void;
  19386. }
  19387. /**
  19388. * Interface used to define a physics engine
  19389. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19390. */
  19391. export interface IPhysicsEngine {
  19392. /**
  19393. * Gets the gravity vector used by the simulation
  19394. */
  19395. gravity: Vector3;
  19396. /**
  19397. * Sets the gravity vector used by the simulation
  19398. * @param gravity defines the gravity vector to use
  19399. */
  19400. setGravity(gravity: Vector3): void;
  19401. /**
  19402. * Set the time step of the physics engine.
  19403. * Default is 1/60.
  19404. * To slow it down, enter 1/600 for example.
  19405. * To speed it up, 1/30
  19406. * @param newTimeStep the new timestep to apply to this world.
  19407. */
  19408. setTimeStep(newTimeStep: number): void;
  19409. /**
  19410. * Get the time step of the physics engine.
  19411. * @returns the current time step
  19412. */
  19413. getTimeStep(): number;
  19414. /**
  19415. * Release all resources
  19416. */
  19417. dispose(): void;
  19418. /**
  19419. * Gets the name of the current physics plugin
  19420. * @returns the name of the plugin
  19421. */
  19422. getPhysicsPluginName(): string;
  19423. /**
  19424. * Adding a new impostor for the impostor tracking.
  19425. * This will be done by the impostor itself.
  19426. * @param impostor the impostor to add
  19427. */
  19428. addImpostor(impostor: PhysicsImpostor): void;
  19429. /**
  19430. * Remove an impostor from the engine.
  19431. * This impostor and its mesh will not longer be updated by the physics engine.
  19432. * @param impostor the impostor to remove
  19433. */
  19434. removeImpostor(impostor: PhysicsImpostor): void;
  19435. /**
  19436. * Add a joint to the physics engine
  19437. * @param mainImpostor defines the main impostor to which the joint is added.
  19438. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19439. * @param joint defines the joint that will connect both impostors.
  19440. */
  19441. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19442. /**
  19443. * Removes a joint from the simulation
  19444. * @param mainImpostor defines the impostor used with the joint
  19445. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19446. * @param joint defines the joint to remove
  19447. */
  19448. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19449. /**
  19450. * Gets the current plugin used to run the simulation
  19451. * @returns current plugin
  19452. */
  19453. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19454. /**
  19455. * Gets the list of physic impostors
  19456. * @returns an array of PhysicsImpostor
  19457. */
  19458. getImpostors(): Array<PhysicsImpostor>;
  19459. /**
  19460. * Gets the impostor for a physics enabled object
  19461. * @param object defines the object impersonated by the impostor
  19462. * @returns the PhysicsImpostor or null if not found
  19463. */
  19464. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19465. /**
  19466. * Gets the impostor for a physics body object
  19467. * @param body defines physics body used by the impostor
  19468. * @returns the PhysicsImpostor or null if not found
  19469. */
  19470. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19471. /**
  19472. * Does a raycast in the physics world
  19473. * @param from when should the ray start?
  19474. * @param to when should the ray end?
  19475. * @returns PhysicsRaycastResult
  19476. */
  19477. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19478. /**
  19479. * Called by the scene. No need to call it.
  19480. * @param delta defines the timespam between frames
  19481. */ step(delta: number): void;
  19482. }
  19483. }
  19484. declare module BABYLON {
  19485. /**
  19486. * The interface for the physics imposter parameters
  19487. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19488. */
  19489. export interface PhysicsImpostorParameters {
  19490. /**
  19491. * The mass of the physics imposter
  19492. */
  19493. mass: number;
  19494. /**
  19495. * The friction of the physics imposter
  19496. */
  19497. friction?: number;
  19498. /**
  19499. * The coefficient of restitution of the physics imposter
  19500. */
  19501. restitution?: number;
  19502. /**
  19503. * The native options of the physics imposter
  19504. */
  19505. nativeOptions?: any;
  19506. /**
  19507. * Specifies if the parent should be ignored
  19508. */
  19509. ignoreParent?: boolean;
  19510. /**
  19511. * Specifies if bi-directional transformations should be disabled
  19512. */
  19513. disableBidirectionalTransformation?: boolean;
  19514. /**
  19515. * The pressure inside the physics imposter, soft object only
  19516. */
  19517. pressure?: number;
  19518. /**
  19519. * The stiffness the physics imposter, soft object only
  19520. */
  19521. stiffness?: number;
  19522. /**
  19523. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  19524. */
  19525. velocityIterations?: number;
  19526. /**
  19527. * The number of iterations used in maintaining consistent vertex positions, soft object only
  19528. */
  19529. positionIterations?: number;
  19530. /**
  19531. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  19532. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  19533. * Add to fix multiple points
  19534. */
  19535. fixedPoints?: number;
  19536. /**
  19537. * The collision margin around a soft object
  19538. */
  19539. margin?: number;
  19540. /**
  19541. * The collision margin around a soft object
  19542. */
  19543. damping?: number;
  19544. /**
  19545. * The path for a rope based on an extrusion
  19546. */
  19547. path?: any;
  19548. /**
  19549. * The shape of an extrusion used for a rope based on an extrusion
  19550. */
  19551. shape?: any;
  19552. }
  19553. /**
  19554. * Interface for a physics-enabled object
  19555. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19556. */
  19557. export interface IPhysicsEnabledObject {
  19558. /**
  19559. * The position of the physics-enabled object
  19560. */
  19561. position: Vector3;
  19562. /**
  19563. * The rotation of the physics-enabled object
  19564. */
  19565. rotationQuaternion: Nullable<Quaternion>;
  19566. /**
  19567. * The scale of the physics-enabled object
  19568. */
  19569. scaling: Vector3;
  19570. /**
  19571. * The rotation of the physics-enabled object
  19572. */
  19573. rotation?: Vector3;
  19574. /**
  19575. * The parent of the physics-enabled object
  19576. */
  19577. parent?: any;
  19578. /**
  19579. * The bounding info of the physics-enabled object
  19580. * @returns The bounding info of the physics-enabled object
  19581. */
  19582. getBoundingInfo(): BoundingInfo;
  19583. /**
  19584. * Computes the world matrix
  19585. * @param force Specifies if the world matrix should be computed by force
  19586. * @returns A world matrix
  19587. */
  19588. computeWorldMatrix(force: boolean): Matrix;
  19589. /**
  19590. * Gets the world matrix
  19591. * @returns A world matrix
  19592. */
  19593. getWorldMatrix?(): Matrix;
  19594. /**
  19595. * Gets the child meshes
  19596. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19597. * @returns An array of abstract meshes
  19598. */
  19599. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19600. /**
  19601. * Gets the vertex data
  19602. * @param kind The type of vertex data
  19603. * @returns A nullable array of numbers, or a float32 array
  19604. */
  19605. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19606. /**
  19607. * Gets the indices from the mesh
  19608. * @returns A nullable array of index arrays
  19609. */
  19610. getIndices?(): Nullable<IndicesArray>;
  19611. /**
  19612. * Gets the scene from the mesh
  19613. * @returns the indices array or null
  19614. */
  19615. getScene?(): Scene;
  19616. /**
  19617. * Gets the absolute position from the mesh
  19618. * @returns the absolute position
  19619. */
  19620. getAbsolutePosition(): Vector3;
  19621. /**
  19622. * Gets the absolute pivot point from the mesh
  19623. * @returns the absolute pivot point
  19624. */
  19625. getAbsolutePivotPoint(): Vector3;
  19626. /**
  19627. * Rotates the mesh
  19628. * @param axis The axis of rotation
  19629. * @param amount The amount of rotation
  19630. * @param space The space of the rotation
  19631. * @returns The rotation transform node
  19632. */
  19633. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19634. /**
  19635. * Translates the mesh
  19636. * @param axis The axis of translation
  19637. * @param distance The distance of translation
  19638. * @param space The space of the translation
  19639. * @returns The transform node
  19640. */
  19641. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19642. /**
  19643. * Sets the absolute position of the mesh
  19644. * @param absolutePosition The absolute position of the mesh
  19645. * @returns The transform node
  19646. */
  19647. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19648. /**
  19649. * Gets the class name of the mesh
  19650. * @returns The class name
  19651. */
  19652. getClassName(): string;
  19653. }
  19654. /**
  19655. * Represents a physics imposter
  19656. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19657. */
  19658. export class PhysicsImpostor {
  19659. /**
  19660. * The physics-enabled object used as the physics imposter
  19661. */
  19662. object: IPhysicsEnabledObject;
  19663. /**
  19664. * The type of the physics imposter
  19665. */
  19666. type: number;
  19667. private _options;
  19668. private _scene?;
  19669. /**
  19670. * The default object size of the imposter
  19671. */
  19672. static DEFAULT_OBJECT_SIZE: Vector3;
  19673. /**
  19674. * The identity quaternion of the imposter
  19675. */
  19676. static IDENTITY_QUATERNION: Quaternion;
  19677. /** @hidden */ pluginData: any;
  19678. private _physicsEngine;
  19679. private _physicsBody;
  19680. private _bodyUpdateRequired;
  19681. private _onBeforePhysicsStepCallbacks;
  19682. private _onAfterPhysicsStepCallbacks;
  19683. /** @hidden */ onPhysicsCollideCallbacks: Array<{
  19684. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19685. otherImpostors: Array<PhysicsImpostor>;
  19686. }>;
  19687. private _deltaPosition;
  19688. private _deltaRotation;
  19689. private _deltaRotationConjugated;
  19690. /** hidden */ isFromLine: boolean;
  19691. private _parent;
  19692. private _isDisposed;
  19693. private static _tmpVecs;
  19694. private static _tmpQuat;
  19695. /**
  19696. * Specifies if the physics imposter is disposed
  19697. */
  19698. readonly isDisposed: boolean;
  19699. /**
  19700. * Gets the mass of the physics imposter
  19701. */
  19702. mass: number;
  19703. /**
  19704. * Gets the coefficient of friction
  19705. */
  19706. /**
  19707. * Sets the coefficient of friction
  19708. */
  19709. friction: number;
  19710. /**
  19711. * Gets the coefficient of restitution
  19712. */
  19713. /**
  19714. * Sets the coefficient of restitution
  19715. */
  19716. restitution: number;
  19717. /**
  19718. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  19719. */
  19720. /**
  19721. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  19722. */
  19723. pressure: number;
  19724. /**
  19725. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  19726. */
  19727. /**
  19728. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  19729. */
  19730. stiffness: number;
  19731. /**
  19732. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  19733. */
  19734. /**
  19735. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  19736. */
  19737. velocityIterations: number;
  19738. /**
  19739. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  19740. */
  19741. /**
  19742. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  19743. */
  19744. positionIterations: number;
  19745. /**
  19746. * The unique id of the physics imposter
  19747. * set by the physics engine when adding this impostor to the array
  19748. */
  19749. uniqueId: number;
  19750. /**
  19751. * @hidden
  19752. */
  19753. soft: boolean;
  19754. /**
  19755. * @hidden
  19756. */
  19757. segments: number;
  19758. private _joints;
  19759. /**
  19760. * Initializes the physics imposter
  19761. * @param object The physics-enabled object used as the physics imposter
  19762. * @param type The type of the physics imposter
  19763. * @param _options The options for the physics imposter
  19764. * @param _scene The Babylon scene
  19765. */
  19766. constructor(
  19767. /**
  19768. * The physics-enabled object used as the physics imposter
  19769. */
  19770. object: IPhysicsEnabledObject,
  19771. /**
  19772. * The type of the physics imposter
  19773. */
  19774. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19775. /**
  19776. * This function will completly initialize this impostor.
  19777. * It will create a new body - but only if this mesh has no parent.
  19778. * If it has, this impostor will not be used other than to define the impostor
  19779. * of the child mesh.
  19780. * @hidden
  19781. */ init(): void;
  19782. private _getPhysicsParent;
  19783. /**
  19784. * Should a new body be generated.
  19785. * @returns boolean specifying if body initialization is required
  19786. */
  19787. isBodyInitRequired(): boolean;
  19788. /**
  19789. * Sets the updated scaling
  19790. * @param updated Specifies if the scaling is updated
  19791. */
  19792. setScalingUpdated(): void;
  19793. /**
  19794. * Force a regeneration of this or the parent's impostor's body.
  19795. * Use under cautious - This will remove all joints already implemented.
  19796. */
  19797. forceUpdate(): void;
  19798. /**
  19799. * Gets the body that holds this impostor. Either its own, or its parent.
  19800. */
  19801. /**
  19802. * Set the physics body. Used mainly by the physics engine/plugin
  19803. */
  19804. physicsBody: any;
  19805. /**
  19806. * Get the parent of the physics imposter
  19807. * @returns Physics imposter or null
  19808. */
  19809. /**
  19810. * Sets the parent of the physics imposter
  19811. */
  19812. parent: Nullable<PhysicsImpostor>;
  19813. /**
  19814. * Resets the update flags
  19815. */
  19816. resetUpdateFlags(): void;
  19817. /**
  19818. * Gets the object extend size
  19819. * @returns the object extend size
  19820. */
  19821. getObjectExtendSize(): Vector3;
  19822. /**
  19823. * Gets the object center
  19824. * @returns The object center
  19825. */
  19826. getObjectCenter(): Vector3;
  19827. /**
  19828. * Get a specific parametes from the options parameter
  19829. * @param paramName The object parameter name
  19830. * @returns The object parameter
  19831. */
  19832. getParam(paramName: string): any;
  19833. /**
  19834. * Sets a specific parameter in the options given to the physics plugin
  19835. * @param paramName The parameter name
  19836. * @param value The value of the parameter
  19837. */
  19838. setParam(paramName: string, value: number): void;
  19839. /**
  19840. * Specifically change the body's mass option. Won't recreate the physics body object
  19841. * @param mass The mass of the physics imposter
  19842. */
  19843. setMass(mass: number): void;
  19844. /**
  19845. * Gets the linear velocity
  19846. * @returns linear velocity or null
  19847. */
  19848. getLinearVelocity(): Nullable<Vector3>;
  19849. /**
  19850. * Sets the linear velocity
  19851. * @param velocity linear velocity or null
  19852. */
  19853. setLinearVelocity(velocity: Nullable<Vector3>): void;
  19854. /**
  19855. * Gets the angular velocity
  19856. * @returns angular velocity or null
  19857. */
  19858. getAngularVelocity(): Nullable<Vector3>;
  19859. /**
  19860. * Sets the angular velocity
  19861. * @param velocity The velocity or null
  19862. */
  19863. setAngularVelocity(velocity: Nullable<Vector3>): void;
  19864. /**
  19865. * Execute a function with the physics plugin native code
  19866. * Provide a function the will have two variables - the world object and the physics body object
  19867. * @param func The function to execute with the physics plugin native code
  19868. */
  19869. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  19870. /**
  19871. * Register a function that will be executed before the physics world is stepping forward
  19872. * @param func The function to execute before the physics world is stepped forward
  19873. */
  19874. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19875. /**
  19876. * Unregister a function that will be executed before the physics world is stepping forward
  19877. * @param func The function to execute before the physics world is stepped forward
  19878. */
  19879. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19880. /**
  19881. * Register a function that will be executed after the physics step
  19882. * @param func The function to execute after physics step
  19883. */
  19884. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19885. /**
  19886. * Unregisters a function that will be executed after the physics step
  19887. * @param func The function to execute after physics step
  19888. */
  19889. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19890. /**
  19891. * register a function that will be executed when this impostor collides against a different body
  19892. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  19893. * @param func Callback that is executed on collision
  19894. */
  19895. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  19896. /**
  19897. * Unregisters the physics imposter on contact
  19898. * @param collideAgainst The physics object to collide against
  19899. * @param func Callback to execute on collision
  19900. */
  19901. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  19902. private _tmpQuat;
  19903. private _tmpQuat2;
  19904. /**
  19905. * Get the parent rotation
  19906. * @returns The parent rotation
  19907. */
  19908. getParentsRotation(): Quaternion;
  19909. /**
  19910. * this function is executed by the physics engine.
  19911. */
  19912. beforeStep: () => void;
  19913. /**
  19914. * this function is executed by the physics engine
  19915. */
  19916. afterStep: () => void;
  19917. /**
  19918. * Legacy collision detection event support
  19919. */
  19920. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  19921. /**
  19922. * event and body object due to cannon's event-based architecture.
  19923. */
  19924. onCollide: (e: {
  19925. body: any;
  19926. }) => void;
  19927. /**
  19928. * Apply a force
  19929. * @param force The force to apply
  19930. * @param contactPoint The contact point for the force
  19931. * @returns The physics imposter
  19932. */
  19933. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19934. /**
  19935. * Apply an impulse
  19936. * @param force The impulse force
  19937. * @param contactPoint The contact point for the impulse force
  19938. * @returns The physics imposter
  19939. */
  19940. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19941. /**
  19942. * A help function to create a joint
  19943. * @param otherImpostor A physics imposter used to create a joint
  19944. * @param jointType The type of joint
  19945. * @param jointData The data for the joint
  19946. * @returns The physics imposter
  19947. */
  19948. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  19949. /**
  19950. * Add a joint to this impostor with a different impostor
  19951. * @param otherImpostor A physics imposter used to add a joint
  19952. * @param joint The joint to add
  19953. * @returns The physics imposter
  19954. */
  19955. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  19956. /**
  19957. * Add an anchor to a cloth impostor
  19958. * @param otherImpostor rigid impostor to anchor to
  19959. * @param width ratio across width from 0 to 1
  19960. * @param height ratio up height from 0 to 1
  19961. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  19962. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  19963. * @returns impostor the soft imposter
  19964. */
  19965. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  19966. /**
  19967. * Add a hook to a rope impostor
  19968. * @param otherImpostor rigid impostor to anchor to
  19969. * @param length ratio across rope from 0 to 1
  19970. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  19971. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  19972. * @returns impostor the rope imposter
  19973. */
  19974. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  19975. /**
  19976. * Will keep this body still, in a sleep mode.
  19977. * @returns the physics imposter
  19978. */
  19979. sleep(): PhysicsImpostor;
  19980. /**
  19981. * Wake the body up.
  19982. * @returns The physics imposter
  19983. */
  19984. wakeUp(): PhysicsImpostor;
  19985. /**
  19986. * Clones the physics imposter
  19987. * @param newObject The physics imposter clones to this physics-enabled object
  19988. * @returns A nullable physics imposter
  19989. */
  19990. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19991. /**
  19992. * Disposes the physics imposter
  19993. */
  19994. dispose(): void;
  19995. /**
  19996. * Sets the delta position
  19997. * @param position The delta position amount
  19998. */
  19999. setDeltaPosition(position: Vector3): void;
  20000. /**
  20001. * Sets the delta rotation
  20002. * @param rotation The delta rotation amount
  20003. */
  20004. setDeltaRotation(rotation: Quaternion): void;
  20005. /**
  20006. * Gets the box size of the physics imposter and stores the result in the input parameter
  20007. * @param result Stores the box size
  20008. * @returns The physics imposter
  20009. */
  20010. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20011. /**
  20012. * Gets the radius of the physics imposter
  20013. * @returns Radius of the physics imposter
  20014. */
  20015. getRadius(): number;
  20016. /**
  20017. * Sync a bone with this impostor
  20018. * @param bone The bone to sync to the impostor.
  20019. * @param boneMesh The mesh that the bone is influencing.
  20020. * @param jointPivot The pivot of the joint / bone in local space.
  20021. * @param distToJoint Optional distance from the impostor to the joint.
  20022. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20023. */
  20024. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20025. /**
  20026. * Sync impostor to a bone
  20027. * @param bone The bone that the impostor will be synced to.
  20028. * @param boneMesh The mesh that the bone is influencing.
  20029. * @param jointPivot The pivot of the joint / bone in local space.
  20030. * @param distToJoint Optional distance from the impostor to the joint.
  20031. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20032. * @param boneAxis Optional vector3 axis the bone is aligned with
  20033. */
  20034. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20035. /**
  20036. * No-Imposter type
  20037. */
  20038. static NoImpostor: number;
  20039. /**
  20040. * Sphere-Imposter type
  20041. */
  20042. static SphereImpostor: number;
  20043. /**
  20044. * Box-Imposter type
  20045. */
  20046. static BoxImpostor: number;
  20047. /**
  20048. * Plane-Imposter type
  20049. */
  20050. static PlaneImpostor: number;
  20051. /**
  20052. * Mesh-imposter type
  20053. */
  20054. static MeshImpostor: number;
  20055. /**
  20056. * Cylinder-Imposter type
  20057. */
  20058. static CylinderImpostor: number;
  20059. /**
  20060. * Particle-Imposter type
  20061. */
  20062. static ParticleImpostor: number;
  20063. /**
  20064. * Heightmap-Imposter type
  20065. */
  20066. static HeightmapImpostor: number;
  20067. /**
  20068. * ConvexHull-Impostor type (Ammo.js plugin only)
  20069. */
  20070. static ConvexHullImpostor: number;
  20071. /**
  20072. * Rope-Imposter type
  20073. */
  20074. static RopeImpostor: number;
  20075. /**
  20076. * Cloth-Imposter type
  20077. */
  20078. static ClothImpostor: number;
  20079. /**
  20080. * Softbody-Imposter type
  20081. */
  20082. static SoftbodyImpostor: number;
  20083. }
  20084. }
  20085. declare module BABYLON {
  20086. /**
  20087. * Class used to represent a specific level of detail of a mesh
  20088. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20089. */
  20090. export class MeshLODLevel {
  20091. /** Defines the distance where this level should star being displayed */
  20092. distance: number;
  20093. /** Defines the mesh to use to render this level */
  20094. mesh: Nullable<Mesh>;
  20095. /**
  20096. * Creates a new LOD level
  20097. * @param distance defines the distance where this level should star being displayed
  20098. * @param mesh defines the mesh to use to render this level
  20099. */
  20100. constructor(
  20101. /** Defines the distance where this level should star being displayed */
  20102. distance: number,
  20103. /** Defines the mesh to use to render this level */
  20104. mesh: Nullable<Mesh>);
  20105. }
  20106. /**
  20107. * @hidden
  20108. **/
  20109. export class _CreationDataStorage {
  20110. closePath?: boolean;
  20111. closeArray?: boolean;
  20112. idx: number[];
  20113. dashSize: number;
  20114. gapSize: number;
  20115. path3D: Path3D;
  20116. pathArray: Vector3[][];
  20117. arc: number;
  20118. radius: number;
  20119. cap: number;
  20120. tessellation: number;
  20121. }
  20122. /**
  20123. * @hidden
  20124. **/ private class _InstanceDataStorage {
  20125. visibleInstances: any;
  20126. renderIdForInstances: number[];
  20127. batchCache: _InstancesBatch;
  20128. instancesBufferSize: number;
  20129. instancesBuffer: Nullable<Buffer>;
  20130. instancesData: Float32Array;
  20131. overridenInstanceCount: number;
  20132. }
  20133. /**
  20134. * @hidden
  20135. **/
  20136. export class _InstancesBatch {
  20137. mustReturn: boolean;
  20138. visibleInstances: Nullable<InstancedMesh[]>[];
  20139. renderSelf: boolean[];
  20140. }
  20141. /**
  20142. * Class used to represent renderable models
  20143. */
  20144. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20145. /**
  20146. * Mesh side orientation : usually the external or front surface
  20147. */
  20148. static readonly FRONTSIDE: number;
  20149. /**
  20150. * Mesh side orientation : usually the internal or back surface
  20151. */
  20152. static readonly BACKSIDE: number;
  20153. /**
  20154. * Mesh side orientation : both internal and external or front and back surfaces
  20155. */
  20156. static readonly DOUBLESIDE: number;
  20157. /**
  20158. * Mesh side orientation : by default, `FRONTSIDE`
  20159. */
  20160. static readonly DEFAULTSIDE: number;
  20161. /**
  20162. * Mesh cap setting : no cap
  20163. */
  20164. static readonly NO_CAP: number;
  20165. /**
  20166. * Mesh cap setting : one cap at the beginning of the mesh
  20167. */
  20168. static readonly CAP_START: number;
  20169. /**
  20170. * Mesh cap setting : one cap at the end of the mesh
  20171. */
  20172. static readonly CAP_END: number;
  20173. /**
  20174. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20175. */
  20176. static readonly CAP_ALL: number;
  20177. /**
  20178. * Gets the default side orientation.
  20179. * @param orientation the orientation to value to attempt to get
  20180. * @returns the default orientation
  20181. * @hidden
  20182. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  20183. private _onBeforeRenderObservable;
  20184. private _onBeforeBindObservable;
  20185. private _onAfterRenderObservable;
  20186. private _onBeforeDrawObservable;
  20187. /**
  20188. * An event triggered before rendering the mesh
  20189. */
  20190. readonly onBeforeRenderObservable: Observable<Mesh>;
  20191. /**
  20192. * An event triggered before binding the mesh
  20193. */
  20194. readonly onBeforeBindObservable: Observable<Mesh>;
  20195. /**
  20196. * An event triggered after rendering the mesh
  20197. */
  20198. readonly onAfterRenderObservable: Observable<Mesh>;
  20199. /**
  20200. * An event triggered before drawing the mesh
  20201. */
  20202. readonly onBeforeDrawObservable: Observable<Mesh>;
  20203. private _onBeforeDrawObserver;
  20204. /**
  20205. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20206. */
  20207. onBeforeDraw: () => void;
  20208. /**
  20209. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20210. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20211. */
  20212. delayLoadState: number;
  20213. /**
  20214. * Gets the list of instances created from this mesh
  20215. * it is not supposed to be modified manually.
  20216. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20217. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20218. */
  20219. instances: InstancedMesh[];
  20220. /**
  20221. * Gets the file containing delay loading data for this mesh
  20222. */
  20223. delayLoadingFile: string;
  20224. /** @hidden */ binaryInfo: any;
  20225. private _LODLevels;
  20226. /**
  20227. * User defined function used to change how LOD level selection is done
  20228. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20229. */
  20230. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20231. private _morphTargetManager;
  20232. /**
  20233. * Gets or sets the morph target manager
  20234. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20235. */
  20236. morphTargetManager: Nullable<MorphTargetManager>;
  20237. /** @hidden */ creationDataStorage: Nullable<_CreationDataStorage>;
  20238. /** @hidden */ geometry: Nullable<Geometry>;
  20239. /** @hidden */ delayInfo: Array<string>;
  20240. /** @hidden */ delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20241. /** @hidden */ instanceDataStorage: _InstanceDataStorage;
  20242. private _effectiveMaterial;
  20243. /** @hidden */ shouldGenerateFlatShading: boolean;
  20244. private _preActivateId;
  20245. /** @hidden */ originalBuilderSideOrientation: number;
  20246. /**
  20247. * Use this property to change the original side orientation defined at construction time
  20248. */
  20249. overrideMaterialSideOrientation: Nullable<number>;
  20250. private _areNormalsFrozen;
  20251. private _sourcePositions;
  20252. private _sourceNormals;
  20253. private _source;
  20254. private meshMap;
  20255. /**
  20256. * Gets the source mesh (the one used to clone this one from)
  20257. */
  20258. readonly source: Nullable<Mesh>;
  20259. /**
  20260. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20261. */
  20262. isUnIndexed: boolean;
  20263. /**
  20264. * @constructor
  20265. * @param name The value used by scene.getMeshByName() to do a lookup.
  20266. * @param scene The scene to add this mesh to.
  20267. * @param parent The parent of this mesh, if it has one
  20268. * @param source An optional Mesh from which geometry is shared, cloned.
  20269. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20270. * When false, achieved by calling a clone(), also passing False.
  20271. * This will make creation of children, recursive.
  20272. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20273. */
  20274. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20275. /**
  20276. * Gets the class name
  20277. * @returns the string "Mesh".
  20278. */
  20279. getClassName(): string;
  20280. /** @hidden */ protected readonly _isMesh: boolean;
  20281. /**
  20282. * Returns a description of this mesh
  20283. * @param fullDetails define if full details about this mesh must be used
  20284. * @returns a descriptive string representing this mesh
  20285. */
  20286. toString(fullDetails?: boolean): string;
  20287. /** @hidden */ unBindEffect(): void;
  20288. /**
  20289. * Gets a boolean indicating if this mesh has LOD
  20290. */
  20291. readonly hasLODLevels: boolean;
  20292. /**
  20293. * Gets the list of MeshLODLevel associated with the current mesh
  20294. * @returns an array of MeshLODLevel
  20295. */
  20296. getLODLevels(): MeshLODLevel[];
  20297. private _sortLODLevels;
  20298. /**
  20299. * Add a mesh as LOD level triggered at the given distance.
  20300. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20301. * @param distance The distance from the center of the object to show this level
  20302. * @param mesh The mesh to be added as LOD level (can be null)
  20303. * @return This mesh (for chaining)
  20304. */
  20305. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20306. /**
  20307. * Returns the LOD level mesh at the passed distance or null if not found.
  20308. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20309. * @param distance The distance from the center of the object to show this level
  20310. * @returns a Mesh or `null`
  20311. */
  20312. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20313. /**
  20314. * Remove a mesh from the LOD array
  20315. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20316. * @param mesh defines the mesh to be removed
  20317. * @return This mesh (for chaining)
  20318. */
  20319. removeLODLevel(mesh: Mesh): Mesh;
  20320. /**
  20321. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20322. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20323. * @param camera defines the camera to use to compute distance
  20324. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20325. * @return This mesh (for chaining)
  20326. */
  20327. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20328. /**
  20329. * Gets the mesh internal Geometry object
  20330. */
  20331. readonly geometry: Nullable<Geometry>;
  20332. /**
  20333. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20334. * @returns the total number of vertices
  20335. */
  20336. getTotalVertices(): number;
  20337. /**
  20338. * Returns the content of an associated vertex buffer
  20339. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20340. * - VertexBuffer.PositionKind
  20341. * - VertexBuffer.UVKind
  20342. * - VertexBuffer.UV2Kind
  20343. * - VertexBuffer.UV3Kind
  20344. * - VertexBuffer.UV4Kind
  20345. * - VertexBuffer.UV5Kind
  20346. * - VertexBuffer.UV6Kind
  20347. * - VertexBuffer.ColorKind
  20348. * - VertexBuffer.MatricesIndicesKind
  20349. * - VertexBuffer.MatricesIndicesExtraKind
  20350. * - VertexBuffer.MatricesWeightsKind
  20351. * - VertexBuffer.MatricesWeightsExtraKind
  20352. * @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
  20353. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20354. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20355. */
  20356. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20357. /**
  20358. * Returns the mesh VertexBuffer object from the requested `kind`
  20359. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20360. * - VertexBuffer.PositionKind
  20361. * - VertexBuffer.UVKind
  20362. * - VertexBuffer.UV2Kind
  20363. * - VertexBuffer.UV3Kind
  20364. * - VertexBuffer.UV4Kind
  20365. * - VertexBuffer.UV5Kind
  20366. * - VertexBuffer.UV6Kind
  20367. * - VertexBuffer.ColorKind
  20368. * - VertexBuffer.MatricesIndicesKind
  20369. * - VertexBuffer.MatricesIndicesExtraKind
  20370. * - VertexBuffer.MatricesWeightsKind
  20371. * - VertexBuffer.MatricesWeightsExtraKind
  20372. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20373. */
  20374. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20375. /**
  20376. * Tests if a specific vertex buffer is associated with this mesh
  20377. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20378. * - VertexBuffer.PositionKind
  20379. * - VertexBuffer.UVKind
  20380. * - VertexBuffer.UV2Kind
  20381. * - VertexBuffer.UV3Kind
  20382. * - VertexBuffer.UV4Kind
  20383. * - VertexBuffer.UV5Kind
  20384. * - VertexBuffer.UV6Kind
  20385. * - VertexBuffer.ColorKind
  20386. * - VertexBuffer.MatricesIndicesKind
  20387. * - VertexBuffer.MatricesIndicesExtraKind
  20388. * - VertexBuffer.MatricesWeightsKind
  20389. * - VertexBuffer.MatricesWeightsExtraKind
  20390. * @returns a boolean
  20391. */
  20392. isVerticesDataPresent(kind: string): boolean;
  20393. /**
  20394. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20395. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20396. * - VertexBuffer.PositionKind
  20397. * - VertexBuffer.UVKind
  20398. * - VertexBuffer.UV2Kind
  20399. * - VertexBuffer.UV3Kind
  20400. * - VertexBuffer.UV4Kind
  20401. * - VertexBuffer.UV5Kind
  20402. * - VertexBuffer.UV6Kind
  20403. * - VertexBuffer.ColorKind
  20404. * - VertexBuffer.MatricesIndicesKind
  20405. * - VertexBuffer.MatricesIndicesExtraKind
  20406. * - VertexBuffer.MatricesWeightsKind
  20407. * - VertexBuffer.MatricesWeightsExtraKind
  20408. * @returns a boolean
  20409. */
  20410. isVertexBufferUpdatable(kind: string): boolean;
  20411. /**
  20412. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20413. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20414. * - VertexBuffer.PositionKind
  20415. * - VertexBuffer.UVKind
  20416. * - VertexBuffer.UV2Kind
  20417. * - VertexBuffer.UV3Kind
  20418. * - VertexBuffer.UV4Kind
  20419. * - VertexBuffer.UV5Kind
  20420. * - VertexBuffer.UV6Kind
  20421. * - VertexBuffer.ColorKind
  20422. * - VertexBuffer.MatricesIndicesKind
  20423. * - VertexBuffer.MatricesIndicesExtraKind
  20424. * - VertexBuffer.MatricesWeightsKind
  20425. * - VertexBuffer.MatricesWeightsExtraKind
  20426. * @returns an array of strings
  20427. */
  20428. getVerticesDataKinds(): string[];
  20429. /**
  20430. * Returns a positive integer : the total number of indices in this mesh geometry.
  20431. * @returns the numner of indices or zero if the mesh has no geometry.
  20432. */
  20433. getTotalIndices(): number;
  20434. /**
  20435. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20436. * @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.
  20437. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20438. * @returns the indices array or an empty array if the mesh has no geometry
  20439. */
  20440. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20441. readonly isBlocked: boolean;
  20442. /**
  20443. * Determine if the current mesh is ready to be rendered
  20444. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20445. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20446. * @returns true if all associated assets are ready (material, textures, shaders)
  20447. */
  20448. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20449. /**
  20450. * 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.
  20451. */
  20452. readonly areNormalsFrozen: boolean;
  20453. /**
  20454. * 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.
  20455. * @returns the current mesh
  20456. */
  20457. freezeNormals(): Mesh;
  20458. /**
  20459. * 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
  20460. * @returns the current mesh
  20461. */
  20462. unfreezeNormals(): Mesh;
  20463. /**
  20464. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20465. */
  20466. overridenInstanceCount: number;
  20467. /** @hidden */ preActivate(): Mesh;
  20468. /** @hidden */ preActivateForIntermediateRendering(renderId: number): Mesh;
  20469. /** @hidden */ registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20470. /**
  20471. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20472. * This means the mesh underlying bounding box and sphere are recomputed.
  20473. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20474. * @returns the current mesh
  20475. */
  20476. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20477. /** @hidden */ createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20478. /**
  20479. * This function will subdivide the mesh into multiple submeshes
  20480. * @param count defines the expected number of submeshes
  20481. */
  20482. subdivide(count: number): void;
  20483. /**
  20484. * Copy a FloatArray into a specific associated vertex buffer
  20485. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20486. * - VertexBuffer.PositionKind
  20487. * - VertexBuffer.UVKind
  20488. * - VertexBuffer.UV2Kind
  20489. * - VertexBuffer.UV3Kind
  20490. * - VertexBuffer.UV4Kind
  20491. * - VertexBuffer.UV5Kind
  20492. * - VertexBuffer.UV6Kind
  20493. * - VertexBuffer.ColorKind
  20494. * - VertexBuffer.MatricesIndicesKind
  20495. * - VertexBuffer.MatricesIndicesExtraKind
  20496. * - VertexBuffer.MatricesWeightsKind
  20497. * - VertexBuffer.MatricesWeightsExtraKind
  20498. * @param data defines the data source
  20499. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20500. * @param stride defines the data stride size (can be null)
  20501. * @returns the current mesh
  20502. */
  20503. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20504. /**
  20505. * Flags an associated vertex buffer as updatable
  20506. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20507. * - VertexBuffer.PositionKind
  20508. * - VertexBuffer.UVKind
  20509. * - VertexBuffer.UV2Kind
  20510. * - VertexBuffer.UV3Kind
  20511. * - VertexBuffer.UV4Kind
  20512. * - VertexBuffer.UV5Kind
  20513. * - VertexBuffer.UV6Kind
  20514. * - VertexBuffer.ColorKind
  20515. * - VertexBuffer.MatricesIndicesKind
  20516. * - VertexBuffer.MatricesIndicesExtraKind
  20517. * - VertexBuffer.MatricesWeightsKind
  20518. * - VertexBuffer.MatricesWeightsExtraKind
  20519. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20520. */
  20521. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20522. /**
  20523. * Sets the mesh global Vertex Buffer
  20524. * @param buffer defines the buffer to use
  20525. * @returns the current mesh
  20526. */
  20527. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20528. /**
  20529. * Update a specific associated vertex buffer
  20530. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20531. * - VertexBuffer.PositionKind
  20532. * - VertexBuffer.UVKind
  20533. * - VertexBuffer.UV2Kind
  20534. * - VertexBuffer.UV3Kind
  20535. * - VertexBuffer.UV4Kind
  20536. * - VertexBuffer.UV5Kind
  20537. * - VertexBuffer.UV6Kind
  20538. * - VertexBuffer.ColorKind
  20539. * - VertexBuffer.MatricesIndicesKind
  20540. * - VertexBuffer.MatricesIndicesExtraKind
  20541. * - VertexBuffer.MatricesWeightsKind
  20542. * - VertexBuffer.MatricesWeightsExtraKind
  20543. * @param data defines the data source
  20544. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20545. * @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)
  20546. * @returns the current mesh
  20547. */
  20548. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20549. /**
  20550. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20551. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20552. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20553. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20554. * @returns the current mesh
  20555. */
  20556. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20557. /**
  20558. * Creates a un-shared specific occurence of the geometry for the mesh.
  20559. * @returns the current mesh
  20560. */
  20561. makeGeometryUnique(): Mesh;
  20562. /**
  20563. * Set the index buffer of this mesh
  20564. * @param indices defines the source data
  20565. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20566. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20567. * @returns the current mesh
  20568. */
  20569. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20570. /**
  20571. * Update the current index buffer
  20572. * @param indices defines the source data
  20573. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20574. * @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)
  20575. * @returns the current mesh
  20576. */
  20577. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20578. /**
  20579. * Invert the geometry to move from a right handed system to a left handed one.
  20580. * @returns the current mesh
  20581. */
  20582. toLeftHanded(): Mesh;
  20583. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20584. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20585. /**
  20586. * Registers for this mesh a javascript function called just before the rendering process
  20587. * @param func defines the function to call before rendering this mesh
  20588. * @returns the current mesh
  20589. */
  20590. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20591. /**
  20592. * Disposes a previously registered javascript function called before the rendering
  20593. * @param func defines the function to remove
  20594. * @returns the current mesh
  20595. */
  20596. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20597. /**
  20598. * Registers for this mesh a javascript function called just after the rendering is complete
  20599. * @param func defines the function to call after rendering this mesh
  20600. * @returns the current mesh
  20601. */
  20602. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20603. /**
  20604. * Disposes a previously registered javascript function called after the rendering.
  20605. * @param func defines the function to remove
  20606. * @returns the current mesh
  20607. */
  20608. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20609. /** @hidden */ getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20610. /** @hidden */ renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20611. /** @hidden */ processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20612. /**
  20613. * 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
  20614. * @param subMesh defines the subMesh to render
  20615. * @param enableAlphaMode defines if alpha mode can be changed
  20616. * @returns the current mesh
  20617. */
  20618. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20619. private _onBeforeDraw;
  20620. /**
  20621. * Renormalize the mesh and patch it up if there are no weights
  20622. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20623. * However in the case of zero weights then we set just a single influence to 1.
  20624. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20625. */
  20626. cleanMatrixWeights(): void;
  20627. private normalizeSkinFourWeights;
  20628. private normalizeSkinWeightsAndExtra;
  20629. /**
  20630. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20631. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20632. * the user know there was an issue with importing the mesh
  20633. * @returns a validation object with skinned, valid and report string
  20634. */
  20635. validateSkinning(): {
  20636. skinned: boolean;
  20637. valid: boolean;
  20638. report: string;
  20639. };
  20640. /** @hidden */ checkDelayState(): Mesh;
  20641. private _queueLoad;
  20642. /**
  20643. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20644. * A mesh is in the frustum if its bounding box intersects the frustum
  20645. * @param frustumPlanes defines the frustum to test
  20646. * @returns true if the mesh is in the frustum planes
  20647. */
  20648. isInFrustum(frustumPlanes: Plane[]): boolean;
  20649. /**
  20650. * Sets the mesh material by the material or multiMaterial `id` property
  20651. * @param id is a string identifying the material or the multiMaterial
  20652. * @returns the current mesh
  20653. */
  20654. setMaterialByID(id: string): Mesh;
  20655. /**
  20656. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20657. * @returns an array of IAnimatable
  20658. */
  20659. getAnimatables(): IAnimatable[];
  20660. /**
  20661. * Modifies the mesh geometry according to the passed transformation matrix.
  20662. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20663. * The mesh normals are modified using the same transformation.
  20664. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20665. * @param transform defines the transform matrix to use
  20666. * @see http://doc.babylonjs.com/resources/baking_transformations
  20667. * @returns the current mesh
  20668. */
  20669. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20670. /**
  20671. * Modifies the mesh geometry according to its own current World Matrix.
  20672. * The mesh World Matrix is then reset.
  20673. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20674. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20675. * @see http://doc.babylonjs.com/resources/baking_transformations
  20676. * @returns the current mesh
  20677. */
  20678. bakeCurrentTransformIntoVertices(): Mesh;
  20679. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  20680. /** @hidden */ resetPointsArrayCache(): Mesh;
  20681. /** @hidden */ generatePointsArray(): boolean;
  20682. /**
  20683. * Returns a new Mesh object generated from the current mesh properties.
  20684. * This method must not get confused with createInstance()
  20685. * @param name is a string, the name given to the new mesh
  20686. * @param newParent can be any Node object (default `null`)
  20687. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20688. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20689. * @returns a new mesh
  20690. */
  20691. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20692. /**
  20693. * Releases resources associated with this mesh.
  20694. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20695. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20696. */
  20697. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20698. /**
  20699. * Modifies the mesh geometry according to a displacement map.
  20700. * 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.
  20701. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20702. * @param url is a string, the URL from the image file is to be downloaded.
  20703. * @param minHeight is the lower limit of the displacement.
  20704. * @param maxHeight is the upper limit of the displacement.
  20705. * @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.
  20706. * @param uvOffset is an optional vector2 used to offset UV.
  20707. * @param uvScale is an optional vector2 used to scale UV.
  20708. * @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.
  20709. * @returns the Mesh.
  20710. */
  20711. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20712. /**
  20713. * Modifies the mesh geometry according to a displacementMap buffer.
  20714. * 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.
  20715. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20716. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  20717. * @param heightMapWidth is the width of the buffer image.
  20718. * @param heightMapHeight is the height of the buffer image.
  20719. * @param minHeight is the lower limit of the displacement.
  20720. * @param maxHeight is the upper limit of the displacement.
  20721. * @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.
  20722. * @param uvOffset is an optional vector2 used to offset UV.
  20723. * @param uvScale is an optional vector2 used to scale UV.
  20724. * @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.
  20725. * @returns the Mesh.
  20726. */
  20727. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20728. /**
  20729. * Modify the mesh to get a flat shading rendering.
  20730. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20731. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20732. * @returns current mesh
  20733. */
  20734. convertToFlatShadedMesh(): Mesh;
  20735. /**
  20736. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20737. * In other words, more vertices, no more indices and a single bigger VBO.
  20738. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20739. * @returns current mesh
  20740. */
  20741. convertToUnIndexedMesh(): Mesh;
  20742. /**
  20743. * Inverses facet orientations.
  20744. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20745. * @param flipNormals will also inverts the normals
  20746. * @returns current mesh
  20747. */
  20748. flipFaces(flipNormals?: boolean): Mesh;
  20749. /**
  20750. * Increase the number of facets and hence vertices in a mesh
  20751. * Vertex normals are interpolated from existing vertex normals
  20752. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20753. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  20754. */
  20755. increaseVertices(numberPerEdge: number): void;
  20756. /**
  20757. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  20758. * This will undo any application of covertToFlatShadedMesh
  20759. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20760. */
  20761. forceSharedVertices(): void;
  20762. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  20763. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  20764. /**
  20765. * Creates a new InstancedMesh object from the mesh model.
  20766. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20767. * @param name defines the name of the new instance
  20768. * @returns a new InstancedMesh
  20769. */
  20770. createInstance(name: string): InstancedMesh;
  20771. /**
  20772. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20773. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20774. * @returns the current mesh
  20775. */
  20776. synchronizeInstances(): Mesh;
  20777. /**
  20778. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  20779. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  20780. * This should be used together with the simplification to avoid disappearing triangles.
  20781. * @param successCallback an optional success callback to be called after the optimization finished.
  20782. * @returns the current mesh
  20783. */
  20784. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  20785. /**
  20786. * Serialize current mesh
  20787. * @param serializationObject defines the object which will receive the serialization data
  20788. */
  20789. serialize(serializationObject: any): void;
  20790. /** @hidden */ syncGeometryWithMorphTargetManager(): void;
  20791. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  20792. /**
  20793. * Returns a new Mesh object parsed from the source provided.
  20794. * @param parsedMesh is the source
  20795. * @param scene defines the hosting scene
  20796. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  20797. * @returns a new Mesh
  20798. */
  20799. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  20800. /**
  20801. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  20802. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20803. * @param name defines the name of the mesh to create
  20804. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  20805. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  20806. * @param closePath creates a seam between the first and the last points of each path of the path array
  20807. * @param offset is taken in account only if the `pathArray` is containing a single path
  20808. * @param scene defines the hosting scene
  20809. * @param updatable defines if the mesh must be flagged as updatable
  20810. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20811. * @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)
  20812. * @returns a new Mesh
  20813. */
  20814. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20815. /**
  20816. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  20817. * @param name defines the name of the mesh to create
  20818. * @param radius sets the radius size (float) of the polygon (default 0.5)
  20819. * @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
  20820. * @param scene defines the hosting scene
  20821. * @param updatable defines if the mesh must be flagged as updatable
  20822. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20823. * @returns a new Mesh
  20824. */
  20825. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20826. /**
  20827. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  20828. * @param name defines the name of the mesh to create
  20829. * @param size sets the size (float) of each box side (default 1)
  20830. * @param scene defines the hosting scene
  20831. * @param updatable defines if the mesh must be flagged as updatable
  20832. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20833. * @returns a new Mesh
  20834. */
  20835. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20836. /**
  20837. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  20838. * @param name defines the name of the mesh to create
  20839. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  20840. * @param diameter sets the diameter size (float) of the sphere (default 1)
  20841. * @param scene defines the hosting scene
  20842. * @param updatable defines if the mesh must be flagged as updatable
  20843. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20844. * @returns a new Mesh
  20845. */
  20846. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20847. /**
  20848. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  20849. * @param name defines the name of the mesh to create
  20850. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  20851. * @param diameter sets the diameter size (float) of the sphere (default 1)
  20852. * @param scene defines the hosting scene
  20853. * @returns a new Mesh
  20854. */
  20855. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  20856. /**
  20857. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  20858. * @param name defines the name of the mesh to create
  20859. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  20860. * @param diameterTop set the top cap diameter (floats, default 1)
  20861. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  20862. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  20863. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  20864. * @param scene defines the hosting scene
  20865. * @param updatable defines if the mesh must be flagged as updatable
  20866. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20867. * @returns a new Mesh
  20868. */
  20869. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  20870. /**
  20871. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  20872. * @param name defines the name of the mesh to create
  20873. * @param diameter sets the diameter size (float) of the torus (default 1)
  20874. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  20875. * @param tessellation sets the number of torus sides (postive integer, default 16)
  20876. * @param scene defines the hosting scene
  20877. * @param updatable defines if the mesh must be flagged as updatable
  20878. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20879. * @returns a new Mesh
  20880. */
  20881. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20882. /**
  20883. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  20884. * @param name defines the name of the mesh to create
  20885. * @param radius sets the global radius size (float) of the torus knot (default 2)
  20886. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  20887. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  20888. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  20889. * @param p the number of windings on X axis (positive integers, default 2)
  20890. * @param q the number of windings on Y axis (positive integers, default 3)
  20891. * @param scene defines the hosting scene
  20892. * @param updatable defines if the mesh must be flagged as updatable
  20893. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20894. * @returns a new Mesh
  20895. */
  20896. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20897. /**
  20898. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  20899. * @param name defines the name of the mesh to create
  20900. * @param points is an array successive Vector3
  20901. * @param scene defines the hosting scene
  20902. * @param updatable defines if the mesh must be flagged as updatable
  20903. * @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).
  20904. * @returns a new Mesh
  20905. */
  20906. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  20907. /**
  20908. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  20909. * @param name defines the name of the mesh to create
  20910. * @param points is an array successive Vector3
  20911. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  20912. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  20913. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  20914. * @param scene defines the hosting scene
  20915. * @param updatable defines if the mesh must be flagged as updatable
  20916. * @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)
  20917. * @returns a new Mesh
  20918. */
  20919. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  20920. /**
  20921. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  20922. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  20923. * 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.
  20924. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20925. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20926. * Remember you can only change the shape positions, not their number when updating a polygon.
  20927. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  20928. * @param name defines the name of the mesh to create
  20929. * @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
  20930. * @param scene defines the hosting scene
  20931. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20932. * @param updatable defines if the mesh must be flagged as updatable
  20933. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20934. * @param earcutInjection can be used to inject your own earcut reference
  20935. * @returns a new Mesh
  20936. */
  20937. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  20938. /**
  20939. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  20940. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  20941. * @param name defines the name of the mesh to create
  20942. * @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
  20943. * @param depth defines the height of extrusion
  20944. * @param scene defines the hosting scene
  20945. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20946. * @param updatable defines if the mesh must be flagged as updatable
  20947. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20948. * @param earcutInjection can be used to inject your own earcut reference
  20949. * @returns a new Mesh
  20950. */
  20951. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  20952. /**
  20953. * Creates an extruded shape mesh.
  20954. * 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
  20955. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20956. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20957. * @param name defines the name of the mesh to create
  20958. * @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
  20959. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20960. * @param scale is the value to scale the shape
  20961. * @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
  20962. * @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
  20963. * @param scene defines the hosting scene
  20964. * @param updatable defines if the mesh must be flagged as updatable
  20965. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20966. * @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)
  20967. * @returns a new Mesh
  20968. */
  20969. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20970. /**
  20971. * Creates an custom extruded shape mesh.
  20972. * The custom extrusion is a parametric shape.
  20973. * It has no predefined shape. Its final shape will depend on the input parameters.
  20974. * Please consider using the same method from the MeshBuilder class instead
  20975. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20976. * @param name defines the name of the mesh to create
  20977. * @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
  20978. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20979. * @param scaleFunction is a custom Javascript function called on each path point
  20980. * @param rotationFunction is a custom Javascript function called on each path point
  20981. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  20982. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  20983. * @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
  20984. * @param scene defines the hosting scene
  20985. * @param updatable defines if the mesh must be flagged as updatable
  20986. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20987. * @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)
  20988. * @returns a new Mesh
  20989. */
  20990. 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;
  20991. /**
  20992. * Creates lathe mesh.
  20993. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  20994. * Please consider using the same method from the MeshBuilder class instead
  20995. * @param name defines the name of the mesh to create
  20996. * @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
  20997. * @param radius is the radius value of the lathe
  20998. * @param tessellation is the side number of the lathe.
  20999. * @param scene defines the hosting scene
  21000. * @param updatable defines if the mesh must be flagged as updatable
  21001. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21002. * @returns a new Mesh
  21003. */
  21004. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21005. /**
  21006. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21007. * @param name defines the name of the mesh to create
  21008. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21009. * @param scene defines the hosting scene
  21010. * @param updatable defines if the mesh must be flagged as updatable
  21011. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21012. * @returns a new Mesh
  21013. */
  21014. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21015. /**
  21016. * Creates a ground mesh.
  21017. * Please consider using the same method from the MeshBuilder class instead
  21018. * @param name defines the name of the mesh to create
  21019. * @param width set the width of the ground
  21020. * @param height set the height of the ground
  21021. * @param subdivisions sets the number of subdivisions per side
  21022. * @param scene defines the hosting scene
  21023. * @param updatable defines if the mesh must be flagged as updatable
  21024. * @returns a new Mesh
  21025. */
  21026. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21027. /**
  21028. * Creates a tiled ground mesh.
  21029. * Please consider using the same method from the MeshBuilder class instead
  21030. * @param name defines the name of the mesh to create
  21031. * @param xmin set the ground minimum X coordinate
  21032. * @param zmin set the ground minimum Y coordinate
  21033. * @param xmax set the ground maximum X coordinate
  21034. * @param zmax set the ground maximum Z coordinate
  21035. * @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
  21036. * @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
  21037. * @param scene defines the hosting scene
  21038. * @param updatable defines if the mesh must be flagged as updatable
  21039. * @returns a new Mesh
  21040. */
  21041. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21042. w: number;
  21043. h: number;
  21044. }, precision: {
  21045. w: number;
  21046. h: number;
  21047. }, scene: Scene, updatable?: boolean): Mesh;
  21048. /**
  21049. * Creates a ground mesh from a height map.
  21050. * Please consider using the same method from the MeshBuilder class instead
  21051. * @see http://doc.babylonjs.com/babylon101/height_map
  21052. * @param name defines the name of the mesh to create
  21053. * @param url sets the URL of the height map image resource
  21054. * @param width set the ground width size
  21055. * @param height set the ground height size
  21056. * @param subdivisions sets the number of subdivision per side
  21057. * @param minHeight is the minimum altitude on the ground
  21058. * @param maxHeight is the maximum altitude on the ground
  21059. * @param scene defines the hosting scene
  21060. * @param updatable defines if the mesh must be flagged as updatable
  21061. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21062. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21063. * @returns a new Mesh
  21064. */
  21065. 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;
  21066. /**
  21067. * Creates a tube mesh.
  21068. * The tube is a parametric shape.
  21069. * It has no predefined shape. Its final shape will depend on the input parameters.
  21070. * Please consider using the same method from the MeshBuilder class instead
  21071. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21072. * @param name defines the name of the mesh to create
  21073. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21074. * @param radius sets the tube radius size
  21075. * @param tessellation is the number of sides on the tubular surface
  21076. * @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
  21077. * @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
  21078. * @param scene defines the hosting scene
  21079. * @param updatable defines if the mesh must be flagged as updatable
  21080. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21081. * @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)
  21082. * @returns a new Mesh
  21083. */
  21084. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21085. (i: number, distance: number): number;
  21086. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21087. /**
  21088. * Creates a polyhedron mesh.
  21089. * Please consider using the same method from the MeshBuilder class instead.
  21090. * * 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
  21091. * * The parameter `size` (positive float, default 1) sets the polygon size
  21092. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21093. * * 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`
  21094. * * 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
  21095. * * 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)`)
  21096. * * 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
  21097. * * 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
  21098. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21099. * * If you create a double-sided mesh, you can choose what parts of 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
  21100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21101. * @param name defines the name of the mesh to create
  21102. * @param options defines the options used to create the mesh
  21103. * @param scene defines the hosting scene
  21104. * @returns a new Mesh
  21105. */
  21106. static CreatePolyhedron(name: string, options: {
  21107. type?: number;
  21108. size?: number;
  21109. sizeX?: number;
  21110. sizeY?: number;
  21111. sizeZ?: number;
  21112. custom?: any;
  21113. faceUV?: Vector4[];
  21114. faceColors?: Color4[];
  21115. updatable?: boolean;
  21116. sideOrientation?: number;
  21117. }, scene: Scene): Mesh;
  21118. /**
  21119. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21120. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21121. * * 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`)
  21122. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21123. * * 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
  21124. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21125. * * If you create a double-sided mesh, you can choose what parts of 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
  21126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21127. * @param name defines the name of the mesh
  21128. * @param options defines the options used to create the mesh
  21129. * @param scene defines the hosting scene
  21130. * @returns a new Mesh
  21131. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21132. */
  21133. static CreateIcoSphere(name: string, options: {
  21134. radius?: number;
  21135. flat?: boolean;
  21136. subdivisions?: number;
  21137. sideOrientation?: number;
  21138. updatable?: boolean;
  21139. }, scene: Scene): Mesh;
  21140. /**
  21141. * Creates a decal mesh.
  21142. * Please consider using the same method from the MeshBuilder class instead.
  21143. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21144. * @param name defines the name of the mesh
  21145. * @param sourceMesh defines the mesh receiving the decal
  21146. * @param position sets the position of the decal in world coordinates
  21147. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21148. * @param size sets the decal scaling
  21149. * @param angle sets the angle to rotate the decal
  21150. * @returns a new Mesh
  21151. */
  21152. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21153. /**
  21154. * Prepare internal position array for software CPU skinning
  21155. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21156. */
  21157. setPositionsForCPUSkinning(): Float32Array;
  21158. /**
  21159. * Prepare internal normal array for software CPU skinning
  21160. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21161. */
  21162. setNormalsForCPUSkinning(): Float32Array;
  21163. /**
  21164. * Updates the vertex buffer by applying transformation from the bones
  21165. * @param skeleton defines the skeleton to apply to current mesh
  21166. * @returns the current mesh
  21167. */
  21168. applySkeleton(skeleton: Skeleton): Mesh;
  21169. /**
  21170. * 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
  21171. * @param meshes defines the list of meshes to scan
  21172. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21173. */
  21174. static MinMax(meshes: AbstractMesh[]): {
  21175. min: Vector3;
  21176. max: Vector3;
  21177. };
  21178. /**
  21179. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21180. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21181. * @returns a vector3
  21182. */
  21183. static Center(meshesOrMinMaxVector: {
  21184. min: Vector3;
  21185. max: Vector3;
  21186. } | AbstractMesh[]): Vector3;
  21187. /**
  21188. * Merge the array of meshes into a single mesh for performance reasons.
  21189. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21190. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21191. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21192. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21193. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21194. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21195. * @returns a new mesh
  21196. */
  21197. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21198. /** @hidden */
  21199. addInstance(instance: InstancedMesh): void;
  21200. /** @hidden */
  21201. removeInstance(instance: InstancedMesh): void;
  21202. }
  21203. }
  21204. declare module BABYLON {
  21205. /**
  21206. * Base class for the main features of a material in Babylon.js
  21207. */
  21208. export class Material implements IAnimatable {
  21209. /**
  21210. * Returns the triangle fill mode
  21211. */
  21212. static readonly TriangleFillMode: number;
  21213. /**
  21214. * Returns the wireframe mode
  21215. */
  21216. static readonly WireFrameFillMode: number;
  21217. /**
  21218. * Returns the point fill mode
  21219. */
  21220. static readonly PointFillMode: number;
  21221. /**
  21222. * Returns the point list draw mode
  21223. */
  21224. static readonly PointListDrawMode: number;
  21225. /**
  21226. * Returns the line list draw mode
  21227. */
  21228. static readonly LineListDrawMode: number;
  21229. /**
  21230. * Returns the line loop draw mode
  21231. */
  21232. static readonly LineLoopDrawMode: number;
  21233. /**
  21234. * Returns the line strip draw mode
  21235. */
  21236. static readonly LineStripDrawMode: number;
  21237. /**
  21238. * Returns the triangle strip draw mode
  21239. */
  21240. static readonly TriangleStripDrawMode: number;
  21241. /**
  21242. * Returns the triangle fan draw mode
  21243. */
  21244. static readonly TriangleFanDrawMode: number;
  21245. /**
  21246. * Stores the clock-wise side orientation
  21247. */
  21248. static readonly ClockWiseSideOrientation: number;
  21249. /**
  21250. * Stores the counter clock-wise side orientation
  21251. */
  21252. static readonly CounterClockWiseSideOrientation: number;
  21253. /**
  21254. * The dirty texture flag value
  21255. */
  21256. static readonly TextureDirtyFlag: number;
  21257. /**
  21258. * The dirty light flag value
  21259. */
  21260. static readonly LightDirtyFlag: number;
  21261. /**
  21262. * The dirty fresnel flag value
  21263. */
  21264. static readonly FresnelDirtyFlag: number;
  21265. /**
  21266. * The dirty attribute flag value
  21267. */
  21268. static readonly AttributesDirtyFlag: number;
  21269. /**
  21270. * The dirty misc flag value
  21271. */
  21272. static readonly MiscDirtyFlag: number;
  21273. /**
  21274. * The all dirty flag value
  21275. */
  21276. static readonly AllDirtyFlag: number;
  21277. /**
  21278. * The ID of the material
  21279. */
  21280. id: string;
  21281. /**
  21282. * Gets or sets the unique id of the material
  21283. */
  21284. uniqueId: number;
  21285. /**
  21286. * The name of the material
  21287. */
  21288. name: string;
  21289. /**
  21290. * Gets or sets user defined metadata
  21291. */
  21292. metadata: any;
  21293. /**
  21294. * For internal use only. Please do not use.
  21295. */
  21296. reservedDataStore: any;
  21297. /**
  21298. * Specifies if the ready state should be checked on each call
  21299. */
  21300. checkReadyOnEveryCall: boolean;
  21301. /**
  21302. * Specifies if the ready state should be checked once
  21303. */
  21304. checkReadyOnlyOnce: boolean;
  21305. /**
  21306. * The state of the material
  21307. */
  21308. state: string;
  21309. /**
  21310. * The alpha value of the material
  21311. */
  21312. protected _alpha: number;
  21313. /**
  21314. * List of inspectable custom properties (used by the Inspector)
  21315. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21316. */
  21317. inspectableCustomProperties: IInspectable[];
  21318. /**
  21319. * Sets the alpha value of the material
  21320. */
  21321. /**
  21322. * Gets the alpha value of the material
  21323. */
  21324. alpha: number;
  21325. /**
  21326. * Specifies if back face culling is enabled
  21327. */
  21328. protected _backFaceCulling: boolean;
  21329. /**
  21330. * Sets the back-face culling state
  21331. */
  21332. /**
  21333. * Gets the back-face culling state
  21334. */
  21335. backFaceCulling: boolean;
  21336. /**
  21337. * Stores the value for side orientation
  21338. */
  21339. sideOrientation: number;
  21340. /**
  21341. * Callback triggered when the material is compiled
  21342. */
  21343. onCompiled: (effect: Effect) => void;
  21344. /**
  21345. * Callback triggered when an error occurs
  21346. */
  21347. onError: (effect: Effect, errors: string) => void;
  21348. /**
  21349. * Callback triggered to get the render target textures
  21350. */
  21351. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21352. /**
  21353. * Gets a boolean indicating that current material needs to register RTT
  21354. */
  21355. readonly hasRenderTargetTextures: boolean;
  21356. /**
  21357. * Specifies if the material should be serialized
  21358. */
  21359. doNotSerialize: boolean;
  21360. /**
  21361. * @hidden
  21362. */ storeEffectOnSubMeshes: boolean;
  21363. /**
  21364. * Stores the animations for the material
  21365. */
  21366. animations: Array<Animation>;
  21367. /**
  21368. * An event triggered when the material is disposed
  21369. */
  21370. onDisposeObservable: Observable<Material>;
  21371. /**
  21372. * An observer which watches for dispose events
  21373. */
  21374. private _onDisposeObserver;
  21375. private _onUnBindObservable;
  21376. /**
  21377. * Called during a dispose event
  21378. */
  21379. onDispose: () => void;
  21380. private _onBindObservable;
  21381. /**
  21382. * An event triggered when the material is bound
  21383. */
  21384. readonly onBindObservable: Observable<AbstractMesh>;
  21385. /**
  21386. * An observer which watches for bind events
  21387. */
  21388. private _onBindObserver;
  21389. /**
  21390. * Called during a bind event
  21391. */
  21392. onBind: (Mesh: AbstractMesh) => void;
  21393. /**
  21394. * An event triggered when the material is unbound
  21395. */
  21396. readonly onUnBindObservable: Observable<Material>;
  21397. /**
  21398. * Stores the value of the alpha mode
  21399. */
  21400. private _alphaMode;
  21401. /**
  21402. * Sets the value of the alpha mode.
  21403. *
  21404. * | Value | Type | Description |
  21405. * | --- | --- | --- |
  21406. * | 0 | ALPHA_DISABLE | |
  21407. * | 1 | ALPHA_ADD | |
  21408. * | 2 | ALPHA_COMBINE | |
  21409. * | 3 | ALPHA_SUBTRACT | |
  21410. * | 4 | ALPHA_MULTIPLY | |
  21411. * | 5 | ALPHA_MAXIMIZED | |
  21412. * | 6 | ALPHA_ONEONE | |
  21413. * | 7 | ALPHA_PREMULTIPLIED | |
  21414. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21415. * | 9 | ALPHA_INTERPOLATE | |
  21416. * | 10 | ALPHA_SCREENMODE | |
  21417. *
  21418. */
  21419. /**
  21420. * Gets the value of the alpha mode
  21421. */
  21422. alphaMode: number;
  21423. /**
  21424. * Stores the state of the need depth pre-pass value
  21425. */
  21426. private _needDepthPrePass;
  21427. /**
  21428. * Sets the need depth pre-pass value
  21429. */
  21430. /**
  21431. * Gets the depth pre-pass value
  21432. */
  21433. needDepthPrePass: boolean;
  21434. /**
  21435. * Specifies if depth writing should be disabled
  21436. */
  21437. disableDepthWrite: boolean;
  21438. /**
  21439. * Specifies if depth writing should be forced
  21440. */
  21441. forceDepthWrite: boolean;
  21442. /**
  21443. * Specifies if there should be a separate pass for culling
  21444. */
  21445. separateCullingPass: boolean;
  21446. /**
  21447. * Stores the state specifing if fog should be enabled
  21448. */
  21449. private _fogEnabled;
  21450. /**
  21451. * Sets the state for enabling fog
  21452. */
  21453. /**
  21454. * Gets the value of the fog enabled state
  21455. */
  21456. fogEnabled: boolean;
  21457. /**
  21458. * Stores the size of points
  21459. */
  21460. pointSize: number;
  21461. /**
  21462. * Stores the z offset value
  21463. */
  21464. zOffset: number;
  21465. /**
  21466. * Gets a value specifying if wireframe mode is enabled
  21467. */
  21468. /**
  21469. * Sets the state of wireframe mode
  21470. */
  21471. wireframe: boolean;
  21472. /**
  21473. * Gets the value specifying if point clouds are enabled
  21474. */
  21475. /**
  21476. * Sets the state of point cloud mode
  21477. */
  21478. pointsCloud: boolean;
  21479. /**
  21480. * Gets the material fill mode
  21481. */
  21482. /**
  21483. * Sets the material fill mode
  21484. */
  21485. fillMode: number;
  21486. /**
  21487. * @hidden
  21488. * Stores the effects for the material
  21489. */ effect: Nullable<Effect>;
  21490. /**
  21491. * @hidden
  21492. * Specifies if the material was previously ready
  21493. */ wasPreviouslyReady: boolean;
  21494. /**
  21495. * Specifies if uniform buffers should be used
  21496. */
  21497. private _useUBO;
  21498. /**
  21499. * Stores a reference to the scene
  21500. */
  21501. private _scene;
  21502. /**
  21503. * Stores the fill mode state
  21504. */
  21505. private _fillMode;
  21506. /**
  21507. * Specifies if the depth write state should be cached
  21508. */
  21509. private _cachedDepthWriteState;
  21510. /**
  21511. * Stores the uniform buffer
  21512. */
  21513. protected _uniformBuffer: UniformBuffer;
  21514. /** @hidden */ indexInSceneMaterialArray: number;
  21515. /** @hidden */
  21516. meshMap: Nullable<{
  21517. [id: string]: AbstractMesh | undefined;
  21518. }>;
  21519. /**
  21520. * Creates a material instance
  21521. * @param name defines the name of the material
  21522. * @param scene defines the scene to reference
  21523. * @param doNotAdd specifies if the material should be added to the scene
  21524. */
  21525. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21526. /**
  21527. * Returns a string representation of the current material
  21528. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21529. * @returns a string with material information
  21530. */
  21531. toString(fullDetails?: boolean): string;
  21532. /**
  21533. * Gets the class name of the material
  21534. * @returns a string with the class name of the material
  21535. */
  21536. getClassName(): string;
  21537. /**
  21538. * Specifies if updates for the material been locked
  21539. */
  21540. readonly isFrozen: boolean;
  21541. /**
  21542. * Locks updates for the material
  21543. */
  21544. freeze(): void;
  21545. /**
  21546. * Unlocks updates for the material
  21547. */
  21548. unfreeze(): void;
  21549. /**
  21550. * Specifies if the material is ready to be used
  21551. * @param mesh defines the mesh to check
  21552. * @param useInstances specifies if instances should be used
  21553. * @returns a boolean indicating if the material is ready to be used
  21554. */
  21555. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21556. /**
  21557. * Specifies that the submesh is ready to be used
  21558. * @param mesh defines the mesh to check
  21559. * @param subMesh defines which submesh to check
  21560. * @param useInstances specifies that instances should be used
  21561. * @returns a boolean indicating that the submesh is ready or not
  21562. */
  21563. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21564. /**
  21565. * Returns the material effect
  21566. * @returns the effect associated with the material
  21567. */
  21568. getEffect(): Nullable<Effect>;
  21569. /**
  21570. * Returns the current scene
  21571. * @returns a Scene
  21572. */
  21573. getScene(): Scene;
  21574. /**
  21575. * Specifies if the material will require alpha blending
  21576. * @returns a boolean specifying if alpha blending is needed
  21577. */
  21578. needAlphaBlending(): boolean;
  21579. /**
  21580. * Specifies if the mesh will require alpha blending
  21581. * @param mesh defines the mesh to check
  21582. * @returns a boolean specifying if alpha blending is needed for the mesh
  21583. */
  21584. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21585. /**
  21586. * Specifies if this material should be rendered in alpha test mode
  21587. * @returns a boolean specifying if an alpha test is needed.
  21588. */
  21589. needAlphaTesting(): boolean;
  21590. /**
  21591. * Gets the texture used for the alpha test
  21592. * @returns the texture to use for alpha testing
  21593. */
  21594. getAlphaTestTexture(): Nullable<BaseTexture>;
  21595. /**
  21596. * Marks the material to indicate that it needs to be re-calculated
  21597. */
  21598. markDirty(): void;
  21599. /** @hidden */ preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21600. /**
  21601. * Binds the material to the mesh
  21602. * @param world defines the world transformation matrix
  21603. * @param mesh defines the mesh to bind the material to
  21604. */
  21605. bind(world: Matrix, mesh?: Mesh): void;
  21606. /**
  21607. * Binds the submesh to the material
  21608. * @param world defines the world transformation matrix
  21609. * @param mesh defines the mesh containing the submesh
  21610. * @param subMesh defines the submesh to bind the material to
  21611. */
  21612. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21613. /**
  21614. * Binds the world matrix to the material
  21615. * @param world defines the world transformation matrix
  21616. */
  21617. bindOnlyWorldMatrix(world: Matrix): void;
  21618. /**
  21619. * Binds the scene's uniform buffer to the effect.
  21620. * @param effect defines the effect to bind to the scene uniform buffer
  21621. * @param sceneUbo defines the uniform buffer storing scene data
  21622. */
  21623. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21624. /**
  21625. * Binds the view matrix to the effect
  21626. * @param effect defines the effect to bind the view matrix to
  21627. */
  21628. bindView(effect: Effect): void;
  21629. /**
  21630. * Binds the view projection matrix to the effect
  21631. * @param effect defines the effect to bind the view projection matrix to
  21632. */
  21633. bindViewProjection(effect: Effect): void;
  21634. /**
  21635. * Specifies if material alpha testing should be turned on for the mesh
  21636. * @param mesh defines the mesh to check
  21637. */
  21638. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21639. /**
  21640. * Processes to execute after binding the material to a mesh
  21641. * @param mesh defines the rendered mesh
  21642. */
  21643. protected _afterBind(mesh?: Mesh): void;
  21644. /**
  21645. * Unbinds the material from the mesh
  21646. */
  21647. unbind(): void;
  21648. /**
  21649. * Gets the active textures from the material
  21650. * @returns an array of textures
  21651. */
  21652. getActiveTextures(): BaseTexture[];
  21653. /**
  21654. * Specifies if the material uses a texture
  21655. * @param texture defines the texture to check against the material
  21656. * @returns a boolean specifying if the material uses the texture
  21657. */
  21658. hasTexture(texture: BaseTexture): boolean;
  21659. /**
  21660. * Makes a duplicate of the material, and gives it a new name
  21661. * @param name defines the new name for the duplicated material
  21662. * @returns the cloned material
  21663. */
  21664. clone(name: string): Nullable<Material>;
  21665. /**
  21666. * Gets the meshes bound to the material
  21667. * @returns an array of meshes bound to the material
  21668. */
  21669. getBindedMeshes(): AbstractMesh[];
  21670. /**
  21671. * Force shader compilation
  21672. * @param mesh defines the mesh associated with this material
  21673. * @param onCompiled defines a function to execute once the material is compiled
  21674. * @param options defines the options to configure the compilation
  21675. */
  21676. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21677. clipPlane: boolean;
  21678. }>): void;
  21679. /**
  21680. * Force shader compilation
  21681. * @param mesh defines the mesh that will use this material
  21682. * @param options defines additional options for compiling the shaders
  21683. * @returns a promise that resolves when the compilation completes
  21684. */
  21685. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21686. clipPlane: boolean;
  21687. }>): Promise<void>;
  21688. private static readonly _ImageProcessingDirtyCallBack;
  21689. private static readonly _TextureDirtyCallBack;
  21690. private static readonly _FresnelDirtyCallBack;
  21691. private static readonly _MiscDirtyCallBack;
  21692. private static readonly _LightsDirtyCallBack;
  21693. private static readonly _AttributeDirtyCallBack;
  21694. private static _FresnelAndMiscDirtyCallBack;
  21695. private static _TextureAndMiscDirtyCallBack;
  21696. private static readonly _DirtyCallbackArray;
  21697. private static readonly _RunDirtyCallBacks;
  21698. /**
  21699. * Marks a define in the material to indicate that it needs to be re-computed
  21700. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21701. */
  21702. markAsDirty(flag: number): void;
  21703. /**
  21704. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21705. * @param func defines a function which checks material defines against the submeshes
  21706. */
  21707. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21708. /**
  21709. * Indicates that image processing needs to be re-calculated for all submeshes
  21710. */
  21711. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21712. /**
  21713. * Indicates that textures need to be re-calculated for all submeshes
  21714. */
  21715. protected _markAllSubMeshesAsTexturesDirty(): void;
  21716. /**
  21717. * Indicates that fresnel needs to be re-calculated for all submeshes
  21718. */
  21719. protected _markAllSubMeshesAsFresnelDirty(): void;
  21720. /**
  21721. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21722. */
  21723. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21724. /**
  21725. * Indicates that lights need to be re-calculated for all submeshes
  21726. */
  21727. protected _markAllSubMeshesAsLightsDirty(): void;
  21728. /**
  21729. * Indicates that attributes need to be re-calculated for all submeshes
  21730. */
  21731. protected _markAllSubMeshesAsAttributesDirty(): void;
  21732. /**
  21733. * Indicates that misc needs to be re-calculated for all submeshes
  21734. */
  21735. protected _markAllSubMeshesAsMiscDirty(): void;
  21736. /**
  21737. * Indicates that textures and misc need to be re-calculated for all submeshes
  21738. */
  21739. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21740. /**
  21741. * Disposes the material
  21742. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21743. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21744. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21745. */
  21746. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21747. /** @hidden */
  21748. private releaseVertexArrayObject;
  21749. /**
  21750. * Serializes this material
  21751. * @returns the serialized material object
  21752. */
  21753. serialize(): any;
  21754. /**
  21755. * Creates a material from parsed material data
  21756. * @param parsedMaterial defines parsed material data
  21757. * @param scene defines the hosting scene
  21758. * @param rootUrl defines the root URL to use to load textures
  21759. * @returns a new material
  21760. */
  21761. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21762. }
  21763. }
  21764. declare module BABYLON {
  21765. /**
  21766. * Base class for submeshes
  21767. */
  21768. export class BaseSubMesh {
  21769. /** @hidden */ materialDefines: Nullable<MaterialDefines>;
  21770. /** @hidden */ materialEffect: Nullable<Effect>;
  21771. /**
  21772. * Gets associated effect
  21773. */
  21774. readonly effect: Nullable<Effect>;
  21775. /**
  21776. * Sets associated effect (effect used to render this submesh)
  21777. * @param effect defines the effect to associate with
  21778. * @param defines defines the set of defines used to compile this effect
  21779. */
  21780. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21781. }
  21782. /**
  21783. * Defines a subdivision inside a mesh
  21784. */
  21785. export class SubMesh extends BaseSubMesh implements ICullable {
  21786. /** the material index to use */
  21787. materialIndex: number;
  21788. /** vertex index start */
  21789. verticesStart: number;
  21790. /** vertices count */
  21791. verticesCount: number;
  21792. /** index start */
  21793. indexStart: number;
  21794. /** indices count */
  21795. indexCount: number;
  21796. /** @hidden */ linesIndexCount: number;
  21797. private _mesh;
  21798. private _renderingMesh;
  21799. private _boundingInfo;
  21800. private _linesIndexBuffer;
  21801. /** @hidden */ lastColliderWorldVertices: Nullable<Vector3[]>;
  21802. /** @hidden */ trianglePlanes: Plane[];
  21803. /** @hidden */ lastColliderTransformMatrix: Matrix;
  21804. /** @hidden */ renderId: number;
  21805. /** @hidden */ alphaIndex: number;
  21806. /** @hidden */ distanceToCamera: number;
  21807. /** @hidden */ id: number;
  21808. private _currentMaterial;
  21809. /**
  21810. * Add a new submesh to a mesh
  21811. * @param materialIndex defines the material index to use
  21812. * @param verticesStart defines vertex index start
  21813. * @param verticesCount defines vertices count
  21814. * @param indexStart defines index start
  21815. * @param indexCount defines indices count
  21816. * @param mesh defines the parent mesh
  21817. * @param renderingMesh defines an optional rendering mesh
  21818. * @param createBoundingBox defines if bounding box should be created for this submesh
  21819. * @returns the new submesh
  21820. */
  21821. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21822. /**
  21823. * Creates a new submesh
  21824. * @param materialIndex defines the material index to use
  21825. * @param verticesStart defines vertex index start
  21826. * @param verticesCount defines vertices count
  21827. * @param indexStart defines index start
  21828. * @param indexCount defines indices count
  21829. * @param mesh defines the parent mesh
  21830. * @param renderingMesh defines an optional rendering mesh
  21831. * @param createBoundingBox defines if bounding box should be created for this submesh
  21832. */
  21833. constructor(
  21834. /** the material index to use */
  21835. materialIndex: number,
  21836. /** vertex index start */
  21837. verticesStart: number,
  21838. /** vertices count */
  21839. verticesCount: number,
  21840. /** index start */
  21841. indexStart: number,
  21842. /** indices count */
  21843. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21844. /**
  21845. * Returns true if this submesh covers the entire parent mesh
  21846. * @ignorenaming
  21847. */
  21848. readonly IsGlobal: boolean;
  21849. /**
  21850. * Returns the submesh BoudingInfo object
  21851. * @returns current bounding info (or mesh's one if the submesh is global)
  21852. */
  21853. getBoundingInfo(): BoundingInfo;
  21854. /**
  21855. * Sets the submesh BoundingInfo
  21856. * @param boundingInfo defines the new bounding info to use
  21857. * @returns the SubMesh
  21858. */
  21859. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21860. /**
  21861. * Returns the mesh of the current submesh
  21862. * @return the parent mesh
  21863. */
  21864. getMesh(): AbstractMesh;
  21865. /**
  21866. * Returns the rendering mesh of the submesh
  21867. * @returns the rendering mesh (could be different from parent mesh)
  21868. */
  21869. getRenderingMesh(): Mesh;
  21870. /**
  21871. * Returns the submesh material
  21872. * @returns null or the current material
  21873. */
  21874. getMaterial(): Nullable<Material>;
  21875. /**
  21876. * Sets a new updated BoundingInfo object to the submesh
  21877. * @returns the SubMesh
  21878. */
  21879. refreshBoundingInfo(): SubMesh;
  21880. /** @hidden */ checkCollision(collider: Collider): boolean;
  21881. /**
  21882. * Updates the submesh BoundingInfo
  21883. * @param world defines the world matrix to use to update the bounding info
  21884. * @returns the submesh
  21885. */
  21886. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21887. /**
  21888. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21889. * @param frustumPlanes defines the frustum planes
  21890. * @returns true if the submesh is intersecting with the frustum
  21891. */
  21892. isInFrustum(frustumPlanes: Plane[]): boolean;
  21893. /**
  21894. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21895. * @param frustumPlanes defines the frustum planes
  21896. * @returns true if the submesh is inside the frustum
  21897. */
  21898. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21899. /**
  21900. * Renders the submesh
  21901. * @param enableAlphaMode defines if alpha needs to be used
  21902. * @returns the submesh
  21903. */
  21904. render(enableAlphaMode: boolean): SubMesh;
  21905. /**
  21906. * @hidden
  21907. */ getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  21908. /**
  21909. * Checks if the submesh intersects with a ray
  21910. * @param ray defines the ray to test
  21911. * @returns true is the passed ray intersects the submesh bounding box
  21912. */
  21913. canIntersects(ray: Ray): boolean;
  21914. /**
  21915. * Intersects current submesh with a ray
  21916. * @param ray defines the ray to test
  21917. * @param positions defines mesh's positions array
  21918. * @param indices defines mesh's indices array
  21919. * @param fastCheck defines if only bounding info should be used
  21920. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21921. * @returns intersection info or null if no intersection
  21922. */
  21923. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21924. /** @hidden */
  21925. private _intersectLines;
  21926. /** @hidden */
  21927. private _intersectTriangles;
  21928. /** @hidden */ rebuild(): void;
  21929. /**
  21930. * Creates a new submesh from the passed mesh
  21931. * @param newMesh defines the new hosting mesh
  21932. * @param newRenderingMesh defines an optional rendering mesh
  21933. * @returns the new submesh
  21934. */
  21935. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21936. /**
  21937. * Release associated resources
  21938. */
  21939. dispose(): void;
  21940. /**
  21941. * Gets the class name
  21942. * @returns the string "SubMesh".
  21943. */
  21944. getClassName(): string;
  21945. /**
  21946. * Creates a new submesh from indices data
  21947. * @param materialIndex the index of the main mesh material
  21948. * @param startIndex the index where to start the copy in the mesh indices array
  21949. * @param indexCount the number of indices to copy then from the startIndex
  21950. * @param mesh the main mesh to create the submesh from
  21951. * @param renderingMesh the optional rendering mesh
  21952. * @returns a new submesh
  21953. */
  21954. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21955. }
  21956. }
  21957. declare module BABYLON {
  21958. /**
  21959. * Class used to store geometry data (vertex buffers + index buffer)
  21960. */
  21961. export class Geometry implements IGetSetVerticesData {
  21962. /**
  21963. * Gets or sets the ID of the geometry
  21964. */
  21965. id: string;
  21966. /**
  21967. * Gets or sets the unique ID of the geometry
  21968. */
  21969. uniqueId: number;
  21970. /**
  21971. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21972. */
  21973. delayLoadState: number;
  21974. /**
  21975. * Gets the file containing the data to load when running in delay load state
  21976. */
  21977. delayLoadingFile: Nullable<string>;
  21978. /**
  21979. * Callback called when the geometry is updated
  21980. */
  21981. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21982. private _scene;
  21983. private _engine;
  21984. private _meshes;
  21985. private _totalVertices;
  21986. /** @hidden */ indices: IndicesArray;
  21987. /** @hidden */ vertexBuffers: {
  21988. [key: string]: VertexBuffer;
  21989. };
  21990. private _isDisposed;
  21991. private _extend;
  21992. private _boundingBias;
  21993. /** @hidden */ delayInfo: Array<string>;
  21994. private _indexBuffer;
  21995. private _indexBufferIsUpdatable;
  21996. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  21997. /** @hidden */ delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21998. /** @hidden */ softwareSkinningFrameId: number;
  21999. private _vertexArrayObjects;
  22000. private _updatable;
  22001. /** @hidden */ positions: Nullable<Vector3[]>;
  22002. /**
  22003. * 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
  22004. */
  22005. /**
  22006. * 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
  22007. */
  22008. boundingBias: Vector2;
  22009. /**
  22010. * Static function used to attach a new empty geometry to a mesh
  22011. * @param mesh defines the mesh to attach the geometry to
  22012. * @returns the new Geometry
  22013. */
  22014. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22015. /**
  22016. * Creates a new geometry
  22017. * @param id defines the unique ID
  22018. * @param scene defines the hosting scene
  22019. * @param vertexData defines the VertexData used to get geometry data
  22020. * @param updatable defines if geometry must be updatable (false by default)
  22021. * @param mesh defines the mesh that will be associated with the geometry
  22022. */
  22023. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22024. /**
  22025. * Gets the current extend of the geometry
  22026. */
  22027. readonly extend: {
  22028. minimum: Vector3;
  22029. maximum: Vector3;
  22030. };
  22031. /**
  22032. * Gets the hosting scene
  22033. * @returns the hosting Scene
  22034. */
  22035. getScene(): Scene;
  22036. /**
  22037. * Gets the hosting engine
  22038. * @returns the hosting Engine
  22039. */
  22040. getEngine(): Engine;
  22041. /**
  22042. * Defines if the geometry is ready to use
  22043. * @returns true if the geometry is ready to be used
  22044. */
  22045. isReady(): boolean;
  22046. /**
  22047. * Gets a value indicating that the geometry should not be serialized
  22048. */
  22049. readonly doNotSerialize: boolean;
  22050. /** @hidden */ rebuild(): void;
  22051. /**
  22052. * Affects all geometry data in one call
  22053. * @param vertexData defines the geometry data
  22054. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22055. */
  22056. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22057. /**
  22058. * Set specific vertex data
  22059. * @param kind defines the data kind (Position, normal, etc...)
  22060. * @param data defines the vertex data to use
  22061. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22062. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22063. */
  22064. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22065. /**
  22066. * Removes a specific vertex data
  22067. * @param kind defines the data kind (Position, normal, etc...)
  22068. */
  22069. removeVerticesData(kind: string): void;
  22070. /**
  22071. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22072. * @param buffer defines the vertex buffer to use
  22073. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22074. */
  22075. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22076. /**
  22077. * Update a specific vertex buffer
  22078. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22079. * It will do nothing if the buffer is not updatable
  22080. * @param kind defines the data kind (Position, normal, etc...)
  22081. * @param data defines the data to use
  22082. * @param offset defines the offset in the target buffer where to store the data
  22083. * @param useBytes set to true if the offset is in bytes
  22084. */
  22085. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22086. /**
  22087. * Update a specific vertex buffer
  22088. * This function will create a new buffer if the current one is not updatable
  22089. * @param kind defines the data kind (Position, normal, etc...)
  22090. * @param data defines the data to use
  22091. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22092. */
  22093. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22094. private _updateBoundingInfo;
  22095. /** @hidden */ bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22096. /**
  22097. * Gets total number of vertices
  22098. * @returns the total number of vertices
  22099. */
  22100. getTotalVertices(): number;
  22101. /**
  22102. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22103. * @param kind defines the data kind (Position, normal, etc...)
  22104. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22105. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22106. * @returns a float array containing vertex data
  22107. */
  22108. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22109. /**
  22110. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22111. * @param kind defines the data kind (Position, normal, etc...)
  22112. * @returns true if the vertex buffer with the specified kind is updatable
  22113. */
  22114. isVertexBufferUpdatable(kind: string): boolean;
  22115. /**
  22116. * Gets a specific vertex buffer
  22117. * @param kind defines the data kind (Position, normal, etc...)
  22118. * @returns a VertexBuffer
  22119. */
  22120. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22121. /**
  22122. * Returns all vertex buffers
  22123. * @return an object holding all vertex buffers indexed by kind
  22124. */
  22125. getVertexBuffers(): Nullable<{
  22126. [key: string]: VertexBuffer;
  22127. }>;
  22128. /**
  22129. * Gets a boolean indicating if specific vertex buffer is present
  22130. * @param kind defines the data kind (Position, normal, etc...)
  22131. * @returns true if data is present
  22132. */
  22133. isVerticesDataPresent(kind: string): boolean;
  22134. /**
  22135. * Gets a list of all attached data kinds (Position, normal, etc...)
  22136. * @returns a list of string containing all kinds
  22137. */
  22138. getVerticesDataKinds(): string[];
  22139. /**
  22140. * Update index buffer
  22141. * @param indices defines the indices to store in the index buffer
  22142. * @param offset defines the offset in the target buffer where to store the data
  22143. * @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)
  22144. */
  22145. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22146. /**
  22147. * Creates a new index buffer
  22148. * @param indices defines the indices to store in the index buffer
  22149. * @param totalVertices defines the total number of vertices (could be null)
  22150. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22151. */
  22152. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22153. /**
  22154. * Return the total number of indices
  22155. * @returns the total number of indices
  22156. */
  22157. getTotalIndices(): number;
  22158. /**
  22159. * Gets the index buffer array
  22160. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22161. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22162. * @returns the index buffer array
  22163. */
  22164. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22165. /**
  22166. * Gets the index buffer
  22167. * @return the index buffer
  22168. */
  22169. getIndexBuffer(): Nullable<WebGLBuffer>;
  22170. /** @hidden */ releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22171. /**
  22172. * Release the associated resources for a specific mesh
  22173. * @param mesh defines the source mesh
  22174. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22175. */
  22176. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22177. /**
  22178. * Apply current geometry to a given mesh
  22179. * @param mesh defines the mesh to apply geometry to
  22180. */
  22181. applyToMesh(mesh: Mesh): void;
  22182. private _updateExtend;
  22183. private _applyToMesh;
  22184. private notifyUpdate;
  22185. /**
  22186. * Load the geometry if it was flagged as delay loaded
  22187. * @param scene defines the hosting scene
  22188. * @param onLoaded defines a callback called when the geometry is loaded
  22189. */
  22190. load(scene: Scene, onLoaded?: () => void): void;
  22191. private _queueLoad;
  22192. /**
  22193. * Invert the geometry to move from a right handed system to a left handed one.
  22194. */
  22195. toLeftHanded(): void;
  22196. /** @hidden */ resetPointsArrayCache(): void;
  22197. /** @hidden */ generatePointsArray(): boolean;
  22198. /**
  22199. * Gets a value indicating if the geometry is disposed
  22200. * @returns true if the geometry was disposed
  22201. */
  22202. isDisposed(): boolean;
  22203. private _disposeVertexArrayObjects;
  22204. /**
  22205. * Free all associated resources
  22206. */
  22207. dispose(): void;
  22208. /**
  22209. * Clone the current geometry into a new geometry
  22210. * @param id defines the unique ID of the new geometry
  22211. * @returns a new geometry object
  22212. */
  22213. copy(id: string): Geometry;
  22214. /**
  22215. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22216. * @return a JSON representation of the current geometry data (without the vertices data)
  22217. */
  22218. serialize(): any;
  22219. private toNumberArray;
  22220. /**
  22221. * Serialize all vertices data into a JSON oject
  22222. * @returns a JSON representation of the current geometry data
  22223. */
  22224. serializeVerticeData(): any;
  22225. /**
  22226. * Extracts a clone of a mesh geometry
  22227. * @param mesh defines the source mesh
  22228. * @param id defines the unique ID of the new geometry object
  22229. * @returns the new geometry object
  22230. */
  22231. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22232. /**
  22233. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22234. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22235. * Be aware Math.random() could cause collisions, but:
  22236. * "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"
  22237. * @returns a string containing a new GUID
  22238. */
  22239. static RandomId(): string;
  22240. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22241. private static _CleanMatricesWeights;
  22242. /**
  22243. * Create a new geometry from persisted data (Using .babylon file format)
  22244. * @param parsedVertexData defines the persisted data
  22245. * @param scene defines the hosting scene
  22246. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22247. * @returns the new geometry object
  22248. */
  22249. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22250. }
  22251. }
  22252. declare module BABYLON {
  22253. /**
  22254. * Define an interface for all classes that will get and set the data on vertices
  22255. */
  22256. export interface IGetSetVerticesData {
  22257. /**
  22258. * Gets a boolean indicating if specific vertex data is present
  22259. * @param kind defines the vertex data kind to use
  22260. * @returns true is data kind is present
  22261. */
  22262. isVerticesDataPresent(kind: string): boolean;
  22263. /**
  22264. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22265. * @param kind defines the data kind (Position, normal, etc...)
  22266. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22267. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22268. * @returns a float array containing vertex data
  22269. */
  22270. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22271. /**
  22272. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22273. * @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.
  22274. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22275. * @returns the indices array or an empty array if the mesh has no geometry
  22276. */
  22277. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22278. /**
  22279. * Set specific vertex data
  22280. * @param kind defines the data kind (Position, normal, etc...)
  22281. * @param data defines the vertex data to use
  22282. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22283. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22284. */
  22285. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22286. /**
  22287. * Update a specific associated vertex buffer
  22288. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22289. * - VertexBuffer.PositionKind
  22290. * - VertexBuffer.UVKind
  22291. * - VertexBuffer.UV2Kind
  22292. * - VertexBuffer.UV3Kind
  22293. * - VertexBuffer.UV4Kind
  22294. * - VertexBuffer.UV5Kind
  22295. * - VertexBuffer.UV6Kind
  22296. * - VertexBuffer.ColorKind
  22297. * - VertexBuffer.MatricesIndicesKind
  22298. * - VertexBuffer.MatricesIndicesExtraKind
  22299. * - VertexBuffer.MatricesWeightsKind
  22300. * - VertexBuffer.MatricesWeightsExtraKind
  22301. * @param data defines the data source
  22302. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22303. * @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)
  22304. */
  22305. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22306. /**
  22307. * Creates a new index buffer
  22308. * @param indices defines the indices to store in the index buffer
  22309. * @param totalVertices defines the total number of vertices (could be null)
  22310. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22311. */
  22312. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22313. }
  22314. /**
  22315. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22316. */
  22317. export class VertexData {
  22318. /**
  22319. * Mesh side orientation : usually the external or front surface
  22320. */
  22321. static readonly FRONTSIDE: number;
  22322. /**
  22323. * Mesh side orientation : usually the internal or back surface
  22324. */
  22325. static readonly BACKSIDE: number;
  22326. /**
  22327. * Mesh side orientation : both internal and external or front and back surfaces
  22328. */
  22329. static readonly DOUBLESIDE: number;
  22330. /**
  22331. * Mesh side orientation : by default, `FRONTSIDE`
  22332. */
  22333. static readonly DEFAULTSIDE: number;
  22334. /**
  22335. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22336. */
  22337. positions: Nullable<FloatArray>;
  22338. /**
  22339. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22340. */
  22341. normals: Nullable<FloatArray>;
  22342. /**
  22343. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22344. */
  22345. tangents: Nullable<FloatArray>;
  22346. /**
  22347. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22348. */
  22349. uvs: Nullable<FloatArray>;
  22350. /**
  22351. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22352. */
  22353. uvs2: Nullable<FloatArray>;
  22354. /**
  22355. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22356. */
  22357. uvs3: Nullable<FloatArray>;
  22358. /**
  22359. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22360. */
  22361. uvs4: Nullable<FloatArray>;
  22362. /**
  22363. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22364. */
  22365. uvs5: Nullable<FloatArray>;
  22366. /**
  22367. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22368. */
  22369. uvs6: Nullable<FloatArray>;
  22370. /**
  22371. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22372. */
  22373. colors: Nullable<FloatArray>;
  22374. /**
  22375. * 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).
  22376. */
  22377. matricesIndices: Nullable<FloatArray>;
  22378. /**
  22379. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22380. */
  22381. matricesWeights: Nullable<FloatArray>;
  22382. /**
  22383. * An array extending the number of possible indices
  22384. */
  22385. matricesIndicesExtra: Nullable<FloatArray>;
  22386. /**
  22387. * An array extending the number of possible weights when the number of indices is extended
  22388. */
  22389. matricesWeightsExtra: Nullable<FloatArray>;
  22390. /**
  22391. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22392. */
  22393. indices: Nullable<IndicesArray>;
  22394. /**
  22395. * Uses the passed data array to set the set the values for the specified kind of data
  22396. * @param data a linear array of floating numbers
  22397. * @param kind the type of data that is being set, eg positions, colors etc
  22398. */
  22399. set(data: FloatArray, kind: string): void;
  22400. /**
  22401. * Associates the vertexData to the passed Mesh.
  22402. * Sets it as updatable or not (default `false`)
  22403. * @param mesh the mesh the vertexData is applied to
  22404. * @param updatable when used and having the value true allows new data to update the vertexData
  22405. * @returns the VertexData
  22406. */
  22407. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22408. /**
  22409. * Associates the vertexData to the passed Geometry.
  22410. * Sets it as updatable or not (default `false`)
  22411. * @param geometry the geometry the vertexData is applied to
  22412. * @param updatable when used and having the value true allows new data to update the vertexData
  22413. * @returns VertexData
  22414. */
  22415. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22416. /**
  22417. * Updates the associated mesh
  22418. * @param mesh the mesh to be updated
  22419. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22420. * @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
  22421. * @returns VertexData
  22422. */
  22423. updateMesh(mesh: Mesh): VertexData;
  22424. /**
  22425. * Updates the associated geometry
  22426. * @param geometry the geometry to be updated
  22427. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22428. * @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
  22429. * @returns VertexData.
  22430. */
  22431. updateGeometry(geometry: Geometry): VertexData;
  22432. private _applyTo;
  22433. private _update;
  22434. /**
  22435. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22436. * @param matrix the transforming matrix
  22437. * @returns the VertexData
  22438. */
  22439. transform(matrix: Matrix): VertexData;
  22440. /**
  22441. * Merges the passed VertexData into the current one
  22442. * @param other the VertexData to be merged into the current one
  22443. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22444. * @returns the modified VertexData
  22445. */
  22446. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22447. private _mergeElement;
  22448. private _validate;
  22449. /**
  22450. * Serializes the VertexData
  22451. * @returns a serialized object
  22452. */
  22453. serialize(): any;
  22454. /**
  22455. * Extracts the vertexData from a mesh
  22456. * @param mesh the mesh from which to extract the VertexData
  22457. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22458. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22459. * @returns the object VertexData associated to the passed mesh
  22460. */
  22461. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22462. /**
  22463. * Extracts the vertexData from the geometry
  22464. * @param geometry the geometry from which to extract the VertexData
  22465. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22466. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22467. * @returns the object VertexData associated to the passed mesh
  22468. */
  22469. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22470. private static _ExtractFrom;
  22471. /**
  22472. * Creates the VertexData for a Ribbon
  22473. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22474. * * pathArray array of paths, each of which an array of successive Vector3
  22475. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22476. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22477. * * 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
  22478. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22479. * * 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)
  22480. * * 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)
  22481. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22482. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22483. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22484. * @returns the VertexData of the ribbon
  22485. */
  22486. static CreateRibbon(options: {
  22487. pathArray: Vector3[][];
  22488. closeArray?: boolean;
  22489. closePath?: boolean;
  22490. offset?: number;
  22491. sideOrientation?: number;
  22492. frontUVs?: Vector4;
  22493. backUVs?: Vector4;
  22494. invertUV?: boolean;
  22495. uvs?: Vector2[];
  22496. colors?: Color4[];
  22497. }): VertexData;
  22498. /**
  22499. * Creates the VertexData for a box
  22500. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22501. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22502. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22503. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22504. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22505. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22506. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22507. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22508. * * 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)
  22509. * * 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)
  22510. * @returns the VertexData of the box
  22511. */
  22512. static CreateBox(options: {
  22513. size?: number;
  22514. width?: number;
  22515. height?: number;
  22516. depth?: number;
  22517. faceUV?: Vector4[];
  22518. faceColors?: Color4[];
  22519. sideOrientation?: number;
  22520. frontUVs?: Vector4;
  22521. backUVs?: Vector4;
  22522. }): VertexData;
  22523. /**
  22524. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22525. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22526. * * segments sets the number of horizontal strips optional, default 32
  22527. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22528. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22529. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22530. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22531. * * 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
  22532. * * 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
  22533. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22534. * * 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)
  22535. * * 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)
  22536. * @returns the VertexData of the ellipsoid
  22537. */
  22538. static CreateSphere(options: {
  22539. segments?: number;
  22540. diameter?: number;
  22541. diameterX?: number;
  22542. diameterY?: number;
  22543. diameterZ?: number;
  22544. arc?: number;
  22545. slice?: number;
  22546. sideOrientation?: number;
  22547. frontUVs?: Vector4;
  22548. backUVs?: Vector4;
  22549. }): VertexData;
  22550. /**
  22551. * Creates the VertexData for a cylinder, cone or prism
  22552. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22553. * * height sets the height (y direction) of the cylinder, optional, default 2
  22554. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22555. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22556. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22557. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22558. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22559. * * 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
  22560. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22561. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22562. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22563. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22564. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22565. * * 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)
  22566. * * 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)
  22567. * @returns the VertexData of the cylinder, cone or prism
  22568. */
  22569. static CreateCylinder(options: {
  22570. height?: number;
  22571. diameterTop?: number;
  22572. diameterBottom?: number;
  22573. diameter?: number;
  22574. tessellation?: number;
  22575. subdivisions?: number;
  22576. arc?: number;
  22577. faceColors?: Color4[];
  22578. faceUV?: Vector4[];
  22579. hasRings?: boolean;
  22580. enclose?: boolean;
  22581. sideOrientation?: number;
  22582. frontUVs?: Vector4;
  22583. backUVs?: Vector4;
  22584. }): VertexData;
  22585. /**
  22586. * Creates the VertexData for a torus
  22587. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22588. * * diameter the diameter of the torus, optional default 1
  22589. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22590. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22591. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22592. * * 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)
  22593. * * 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)
  22594. * @returns the VertexData of the torus
  22595. */
  22596. static CreateTorus(options: {
  22597. diameter?: number;
  22598. thickness?: number;
  22599. tessellation?: number;
  22600. sideOrientation?: number;
  22601. frontUVs?: Vector4;
  22602. backUVs?: Vector4;
  22603. }): VertexData;
  22604. /**
  22605. * Creates the VertexData of the LineSystem
  22606. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22607. * - lines an array of lines, each line being an array of successive Vector3
  22608. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22609. * @returns the VertexData of the LineSystem
  22610. */
  22611. static CreateLineSystem(options: {
  22612. lines: Vector3[][];
  22613. colors?: Nullable<Color4[][]>;
  22614. }): VertexData;
  22615. /**
  22616. * Create the VertexData for a DashedLines
  22617. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22618. * - points an array successive Vector3
  22619. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22620. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22621. * - dashNb the intended total number of dashes, optional, default 200
  22622. * @returns the VertexData for the DashedLines
  22623. */
  22624. static CreateDashedLines(options: {
  22625. points: Vector3[];
  22626. dashSize?: number;
  22627. gapSize?: number;
  22628. dashNb?: number;
  22629. }): VertexData;
  22630. /**
  22631. * Creates the VertexData for a Ground
  22632. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22633. * - width the width (x direction) of the ground, optional, default 1
  22634. * - height the height (z direction) of the ground, optional, default 1
  22635. * - subdivisions the number of subdivisions per side, optional, default 1
  22636. * @returns the VertexData of the Ground
  22637. */
  22638. static CreateGround(options: {
  22639. width?: number;
  22640. height?: number;
  22641. subdivisions?: number;
  22642. subdivisionsX?: number;
  22643. subdivisionsY?: number;
  22644. }): VertexData;
  22645. /**
  22646. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22647. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22648. * * xmin the ground minimum X coordinate, optional, default -1
  22649. * * zmin the ground minimum Z coordinate, optional, default -1
  22650. * * xmax the ground maximum X coordinate, optional, default 1
  22651. * * zmax the ground maximum Z coordinate, optional, default 1
  22652. * * 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}
  22653. * * 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}
  22654. * @returns the VertexData of the TiledGround
  22655. */
  22656. static CreateTiledGround(options: {
  22657. xmin: number;
  22658. zmin: number;
  22659. xmax: number;
  22660. zmax: number;
  22661. subdivisions?: {
  22662. w: number;
  22663. h: number;
  22664. };
  22665. precision?: {
  22666. w: number;
  22667. h: number;
  22668. };
  22669. }): VertexData;
  22670. /**
  22671. * Creates the VertexData of the Ground designed from a heightmap
  22672. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22673. * * width the width (x direction) of the ground
  22674. * * height the height (z direction) of the ground
  22675. * * subdivisions the number of subdivisions per side
  22676. * * minHeight the minimum altitude on the ground, optional, default 0
  22677. * * maxHeight the maximum altitude on the ground, optional default 1
  22678. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22679. * * buffer the array holding the image color data
  22680. * * bufferWidth the width of image
  22681. * * bufferHeight the height of image
  22682. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22683. * @returns the VertexData of the Ground designed from a heightmap
  22684. */
  22685. static CreateGroundFromHeightMap(options: {
  22686. width: number;
  22687. height: number;
  22688. subdivisions: number;
  22689. minHeight: number;
  22690. maxHeight: number;
  22691. colorFilter: Color3;
  22692. buffer: Uint8Array;
  22693. bufferWidth: number;
  22694. bufferHeight: number;
  22695. alphaFilter: number;
  22696. }): VertexData;
  22697. /**
  22698. * Creates the VertexData for a Plane
  22699. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22700. * * size sets the width and height of the plane to the value of size, optional default 1
  22701. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22702. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22703. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22704. * * 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)
  22705. * * 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)
  22706. * @returns the VertexData of the box
  22707. */
  22708. static CreatePlane(options: {
  22709. size?: number;
  22710. width?: number;
  22711. height?: number;
  22712. sideOrientation?: number;
  22713. frontUVs?: Vector4;
  22714. backUVs?: Vector4;
  22715. }): VertexData;
  22716. /**
  22717. * Creates the VertexData of the Disc or regular Polygon
  22718. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22719. * * radius the radius of the disc, optional default 0.5
  22720. * * tessellation the number of polygon sides, optional, default 64
  22721. * * 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
  22722. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22723. * * 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)
  22724. * * 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)
  22725. * @returns the VertexData of the box
  22726. */
  22727. static CreateDisc(options: {
  22728. radius?: number;
  22729. tessellation?: number;
  22730. arc?: number;
  22731. sideOrientation?: number;
  22732. frontUVs?: Vector4;
  22733. backUVs?: Vector4;
  22734. }): VertexData;
  22735. /**
  22736. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22737. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22738. * @param polygon a mesh built from polygonTriangulation.build()
  22739. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22740. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22741. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22742. * @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)
  22743. * @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)
  22744. * @returns the VertexData of the Polygon
  22745. */
  22746. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22747. /**
  22748. * Creates the VertexData of the IcoSphere
  22749. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22750. * * radius the radius of the IcoSphere, optional default 1
  22751. * * radiusX allows stretching in the x direction, optional, default radius
  22752. * * radiusY allows stretching in the y direction, optional, default radius
  22753. * * radiusZ allows stretching in the z direction, optional, default radius
  22754. * * flat when true creates a flat shaded mesh, optional, default true
  22755. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22756. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22757. * * 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)
  22758. * * 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)
  22759. * @returns the VertexData of the IcoSphere
  22760. */
  22761. static CreateIcoSphere(options: {
  22762. radius?: number;
  22763. radiusX?: number;
  22764. radiusY?: number;
  22765. radiusZ?: number;
  22766. flat?: boolean;
  22767. subdivisions?: number;
  22768. sideOrientation?: number;
  22769. frontUVs?: Vector4;
  22770. backUVs?: Vector4;
  22771. }): VertexData;
  22772. /**
  22773. * Creates the VertexData for a Polyhedron
  22774. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22775. * * type provided types are:
  22776. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22777. * * 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)
  22778. * * size the size of the IcoSphere, optional default 1
  22779. * * sizeX allows stretching in the x direction, optional, default size
  22780. * * sizeY allows stretching in the y direction, optional, default size
  22781. * * sizeZ allows stretching in the z direction, optional, default size
  22782. * * 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
  22783. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22784. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22785. * * flat when true creates a flat shaded mesh, optional, default true
  22786. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22787. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22788. * * 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)
  22789. * * 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)
  22790. * @returns the VertexData of the Polyhedron
  22791. */
  22792. static CreatePolyhedron(options: {
  22793. type?: number;
  22794. size?: number;
  22795. sizeX?: number;
  22796. sizeY?: number;
  22797. sizeZ?: number;
  22798. custom?: any;
  22799. faceUV?: Vector4[];
  22800. faceColors?: Color4[];
  22801. flat?: boolean;
  22802. sideOrientation?: number;
  22803. frontUVs?: Vector4;
  22804. backUVs?: Vector4;
  22805. }): VertexData;
  22806. /**
  22807. * Creates the VertexData for a TorusKnot
  22808. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22809. * * radius the radius of the torus knot, optional, default 2
  22810. * * tube the thickness of the tube, optional, default 0.5
  22811. * * radialSegments the number of sides on each tube segments, optional, default 32
  22812. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22813. * * p the number of windings around the z axis, optional, default 2
  22814. * * q the number of windings around the x axis, optional, default 3
  22815. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22816. * * 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)
  22817. * * 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)
  22818. * @returns the VertexData of the Torus Knot
  22819. */
  22820. static CreateTorusKnot(options: {
  22821. radius?: number;
  22822. tube?: number;
  22823. radialSegments?: number;
  22824. tubularSegments?: number;
  22825. p?: number;
  22826. q?: number;
  22827. sideOrientation?: number;
  22828. frontUVs?: Vector4;
  22829. backUVs?: Vector4;
  22830. }): VertexData;
  22831. /**
  22832. * Compute normals for given positions and indices
  22833. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22834. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22835. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22836. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22837. * * facetNormals : optional array of facet normals (vector3)
  22838. * * facetPositions : optional array of facet positions (vector3)
  22839. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22840. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22841. * * bInfo : optional bounding info, required for facetPartitioning computation
  22842. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22843. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22844. * * useRightHandedSystem: optional boolean to for right handed system computation
  22845. * * depthSort : optional boolean to enable the facet depth sort computation
  22846. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22847. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22848. */
  22849. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22850. facetNormals?: any;
  22851. facetPositions?: any;
  22852. facetPartitioning?: any;
  22853. ratio?: number;
  22854. bInfo?: any;
  22855. bbSize?: Vector3;
  22856. subDiv?: any;
  22857. useRightHandedSystem?: boolean;
  22858. depthSort?: boolean;
  22859. distanceTo?: Vector3;
  22860. depthSortedFacets?: any;
  22861. }): void;
  22862. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22863. /**
  22864. * Applies VertexData created from the imported parameters to the geometry
  22865. * @param parsedVertexData the parsed data from an imported file
  22866. * @param geometry the geometry to apply the VertexData to
  22867. */
  22868. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22869. }
  22870. }
  22871. declare module BABYLON {
  22872. /**
  22873. * Class containing static functions to help procedurally build meshes
  22874. */
  22875. export class DiscBuilder {
  22876. /**
  22877. * Creates a plane polygonal mesh. By default, this is a disc
  22878. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22879. * * 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
  22880. * * 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
  22881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22882. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22884. * @param name defines the name of the mesh
  22885. * @param options defines the options used to create the mesh
  22886. * @param scene defines the hosting scene
  22887. * @returns the plane polygonal mesh
  22888. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22889. */
  22890. static CreateDisc(name: string, options: {
  22891. radius?: number;
  22892. tessellation?: number;
  22893. arc?: number;
  22894. updatable?: boolean;
  22895. sideOrientation?: number;
  22896. frontUVs?: Vector4;
  22897. backUVs?: Vector4;
  22898. }, scene?: Nullable<Scene>): Mesh;
  22899. }
  22900. }
  22901. declare module BABYLON {
  22902. /**
  22903. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  22904. *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.
  22905. * The SPS is also a particle system. It provides some methods to manage the particles.
  22906. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  22907. *
  22908. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  22909. */
  22910. export class SolidParticleSystem implements IDisposable {
  22911. /**
  22912. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  22913. * Example : var p = SPS.particles[i];
  22914. */
  22915. particles: SolidParticle[];
  22916. /**
  22917. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  22918. */
  22919. nbParticles: number;
  22920. /**
  22921. * If the particles must ever face the camera (default false). Useful for planar particles.
  22922. */
  22923. billboard: boolean;
  22924. /**
  22925. * Recompute normals when adding a shape
  22926. */
  22927. recomputeNormals: boolean;
  22928. /**
  22929. * This a counter ofr your own usage. It's not set by any SPS functions.
  22930. */
  22931. counter: number;
  22932. /**
  22933. * The SPS name. This name is also given to the underlying mesh.
  22934. */
  22935. name: string;
  22936. /**
  22937. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  22938. */
  22939. mesh: Mesh;
  22940. /**
  22941. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  22942. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  22943. */
  22944. vars: any;
  22945. /**
  22946. * This array is populated when the SPS is set as 'pickable'.
  22947. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  22948. * Each element of this array is an object `{idx: int, faceId: int}`.
  22949. * `idx` is the picked particle index in the `SPS.particles` array
  22950. * `faceId` is the picked face index counted within this particle.
  22951. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  22952. */
  22953. pickedParticles: {
  22954. idx: number;
  22955. faceId: number;
  22956. }[];
  22957. /**
  22958. * This array is populated when `enableDepthSort` is set to true.
  22959. * Each element of this array is an instance of the class DepthSortedParticle.
  22960. */
  22961. depthSortedParticles: DepthSortedParticle[];
  22962. /**
  22963. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  22964. * @hidden
  22965. */ bSphereOnly: boolean;
  22966. /**
  22967. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  22968. * @hidden
  22969. */ bSphereRadiusFactor: number;
  22970. private _scene;
  22971. private _positions;
  22972. private _indices;
  22973. private _normals;
  22974. private _colors;
  22975. private _uvs;
  22976. private _indices32;
  22977. private _positions32;
  22978. private _normals32;
  22979. private _fixedNormal32;
  22980. private _colors32;
  22981. private _uvs32;
  22982. private _index;
  22983. private _updatable;
  22984. private _pickable;
  22985. private _isVisibilityBoxLocked;
  22986. private _alwaysVisible;
  22987. private _depthSort;
  22988. private _shapeCounter;
  22989. private _copy;
  22990. private _color;
  22991. private _computeParticleColor;
  22992. private _computeParticleTexture;
  22993. private _computeParticleRotation;
  22994. private _computeParticleVertex;
  22995. private _computeBoundingBox;
  22996. private _depthSortParticles;
  22997. private _camera;
  22998. private _mustUnrotateFixedNormals;
  22999. private _particlesIntersect;
  23000. private _needs32Bits;
  23001. /**
  23002. * Creates a SPS (Solid Particle System) object.
  23003. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23004. * @param scene (Scene) is the scene in which the SPS is added.
  23005. * @param options defines the options of the sps e.g.
  23006. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23007. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23008. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23009. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23010. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23011. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23012. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23013. */
  23014. constructor(name: string, scene: Scene, options?: {
  23015. updatable?: boolean;
  23016. isPickable?: boolean;
  23017. enableDepthSort?: boolean;
  23018. particleIntersection?: boolean;
  23019. boundingSphereOnly?: boolean;
  23020. bSphereRadiusFactor?: number;
  23021. });
  23022. /**
  23023. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23024. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23025. * @returns the created mesh
  23026. */
  23027. buildMesh(): Mesh;
  23028. /**
  23029. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23030. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23031. * Thus the particles generated from `digest()` have their property `position` set yet.
  23032. * @param mesh ( Mesh ) is the mesh to be digested
  23033. * @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
  23034. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23035. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23036. * @returns the current SPS
  23037. */
  23038. digest(mesh: Mesh, options?: {
  23039. facetNb?: number;
  23040. number?: number;
  23041. delta?: number;
  23042. }): SolidParticleSystem;
  23043. private _unrotateFixedNormals;
  23044. private _resetCopy;
  23045. private _meshBuilder;
  23046. private _posToShape;
  23047. private _uvsToShapeUV;
  23048. private _addParticle;
  23049. /**
  23050. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23051. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23052. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23053. * @param nb (positive integer) the number of particles to be created from this model
  23054. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23055. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23056. * @returns the number of shapes in the system
  23057. */
  23058. addShape(mesh: Mesh, nb: number, options?: {
  23059. positionFunction?: any;
  23060. vertexFunction?: any;
  23061. }): number;
  23062. private _rebuildParticle;
  23063. /**
  23064. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23065. * @returns the SPS.
  23066. */
  23067. rebuildMesh(): SolidParticleSystem;
  23068. /**
  23069. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23070. * This method calls `updateParticle()` for each particle of the SPS.
  23071. * For an animated SPS, it is usually called within the render loop.
  23072. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23073. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23074. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23075. * @returns the SPS.
  23076. */
  23077. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23078. /**
  23079. * Disposes the SPS.
  23080. */
  23081. dispose(): void;
  23082. /**
  23083. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23084. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23085. * @returns the SPS.
  23086. */
  23087. refreshVisibleSize(): SolidParticleSystem;
  23088. /**
  23089. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23090. * @param size the size (float) of the visibility box
  23091. * note : this doesn't lock the SPS mesh bounding box.
  23092. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23093. */
  23094. setVisibilityBox(size: number): void;
  23095. /**
  23096. * Gets whether the SPS as always visible or not
  23097. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23098. */
  23099. /**
  23100. * Sets the SPS as always visible or not
  23101. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23102. */
  23103. isAlwaysVisible: boolean;
  23104. /**
  23105. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23106. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23107. */
  23108. /**
  23109. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23110. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23111. */
  23112. isVisibilityBoxLocked: boolean;
  23113. /**
  23114. * Tells to `setParticles()` to compute the particle rotations or not.
  23115. * Default value : true. The SPS is faster when it's set to false.
  23116. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23117. */
  23118. /**
  23119. * Gets if `setParticles()` computes the particle rotations or not.
  23120. * Default value : true. The SPS is faster when it's set to false.
  23121. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23122. */
  23123. computeParticleRotation: boolean;
  23124. /**
  23125. * Tells to `setParticles()` to compute the particle colors or not.
  23126. * Default value : true. The SPS is faster when it's set to false.
  23127. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23128. */
  23129. /**
  23130. * Gets if `setParticles()` computes the particle colors or not.
  23131. * Default value : true. The SPS is faster when it's set to false.
  23132. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23133. */
  23134. computeParticleColor: boolean;
  23135. /**
  23136. * Gets if `setParticles()` computes the particle textures or not.
  23137. * Default value : true. The SPS is faster when it's set to false.
  23138. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23139. */
  23140. computeParticleTexture: boolean;
  23141. /**
  23142. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23143. * Default value : false. The SPS is faster when it's set to false.
  23144. * Note : the particle custom vertex positions aren't stored values.
  23145. */
  23146. /**
  23147. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23148. * Default value : false. The SPS is faster when it's set to false.
  23149. * Note : the particle custom vertex positions aren't stored values.
  23150. */
  23151. computeParticleVertex: boolean;
  23152. /**
  23153. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23154. */
  23155. /**
  23156. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23157. */
  23158. computeBoundingBox: boolean;
  23159. /**
  23160. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23161. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23162. * Default : `true`
  23163. */
  23164. /**
  23165. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23166. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23167. * Default : `true`
  23168. */
  23169. depthSortParticles: boolean;
  23170. /**
  23171. * This function does nothing. It may be overwritten to set all the particle first values.
  23172. * The SPS doesn't call this function, you may have to call it by your own.
  23173. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23174. */
  23175. initParticles(): void;
  23176. /**
  23177. * This function does nothing. It may be overwritten to recycle a particle.
  23178. * The SPS doesn't call this function, you may have to call it by your own.
  23179. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23180. * @param particle The particle to recycle
  23181. * @returns the recycled particle
  23182. */
  23183. recycleParticle(particle: SolidParticle): SolidParticle;
  23184. /**
  23185. * Updates a particle : this function should be overwritten by the user.
  23186. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23187. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23188. * @example : just set a particle position or velocity and recycle conditions
  23189. * @param particle The particle to update
  23190. * @returns the updated particle
  23191. */
  23192. updateParticle(particle: SolidParticle): SolidParticle;
  23193. /**
  23194. * Updates a vertex of a particle : it can be overwritten by the user.
  23195. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23196. * @param particle the current particle
  23197. * @param vertex the current index of the current particle
  23198. * @param pt the index of the current vertex in the particle shape
  23199. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23200. * @example : just set a vertex particle position
  23201. * @returns the updated vertex
  23202. */
  23203. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23204. /**
  23205. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23206. * This does nothing and may be overwritten by the user.
  23207. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23208. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23209. * @param update the boolean update value actually passed to setParticles()
  23210. */
  23211. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23212. /**
  23213. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23214. * This will be passed three parameters.
  23215. * This does nothing and may be overwritten by the user.
  23216. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23217. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23218. * @param update the boolean update value actually passed to setParticles()
  23219. */
  23220. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23221. }
  23222. }
  23223. declare module BABYLON {
  23224. /**
  23225. * Represents one particle of a solid particle system.
  23226. */
  23227. export class SolidParticle {
  23228. /**
  23229. * particle global index
  23230. */
  23231. idx: number;
  23232. /**
  23233. * The color of the particle
  23234. */
  23235. color: Nullable<Color4>;
  23236. /**
  23237. * The world space position of the particle.
  23238. */
  23239. position: Vector3;
  23240. /**
  23241. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23242. */
  23243. rotation: Vector3;
  23244. /**
  23245. * The world space rotation quaternion of the particle.
  23246. */
  23247. rotationQuaternion: Nullable<Quaternion>;
  23248. /**
  23249. * The scaling of the particle.
  23250. */
  23251. scaling: Vector3;
  23252. /**
  23253. * The uvs of the particle.
  23254. */
  23255. uvs: Vector4;
  23256. /**
  23257. * The current speed of the particle.
  23258. */
  23259. velocity: Vector3;
  23260. /**
  23261. * The pivot point in the particle local space.
  23262. */
  23263. pivot: Vector3;
  23264. /**
  23265. * Must the particle be translated from its pivot point in its local space ?
  23266. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23267. * Default : false
  23268. */
  23269. translateFromPivot: boolean;
  23270. /**
  23271. * Is the particle active or not ?
  23272. */
  23273. alive: boolean;
  23274. /**
  23275. * Is the particle visible or not ?
  23276. */
  23277. isVisible: boolean;
  23278. /**
  23279. * Index of this particle in the global "positions" array (Internal use)
  23280. * @hidden
  23281. */ pos: number;
  23282. /**
  23283. * @hidden Index of this particle in the global "indices" array (Internal use)
  23284. */ ind: number;
  23285. /**
  23286. * @hidden ModelShape of this particle (Internal use)
  23287. */ model: ModelShape;
  23288. /**
  23289. * ModelShape id of this particle
  23290. */
  23291. shapeId: number;
  23292. /**
  23293. * Index of the particle in its shape id (Internal use)
  23294. */
  23295. idxInShape: number;
  23296. /**
  23297. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23298. */ modelBoundingInfo: BoundingInfo;
  23299. /**
  23300. * @hidden Particle BoundingInfo object (Internal use)
  23301. */ boundingInfo: BoundingInfo;
  23302. /**
  23303. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23304. */ sps: SolidParticleSystem;
  23305. /**
  23306. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23307. */ stillInvisible: boolean;
  23308. /**
  23309. * @hidden Last computed particle rotation matrix
  23310. */ rotationMatrix: number[];
  23311. /**
  23312. * Parent particle Id, if any.
  23313. * Default null.
  23314. */
  23315. parentId: Nullable<number>;
  23316. /**
  23317. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23318. * The possible values are :
  23319. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23320. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23321. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23322. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23323. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23324. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23325. * */
  23326. cullingStrategy: number;
  23327. /**
  23328. * @hidden Internal global position in the SPS.
  23329. */ globalPosition: Vector3;
  23330. /**
  23331. * Creates a Solid Particle object.
  23332. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23333. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23334. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23335. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23336. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23337. * @param shapeId (integer) is the model shape identifier in the SPS.
  23338. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23339. * @param sps defines the sps it is associated to
  23340. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23341. */
  23342. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23343. /**
  23344. * Legacy support, changed scale to scaling
  23345. */
  23346. /**
  23347. * Legacy support, changed scale to scaling
  23348. */
  23349. scale: Vector3;
  23350. /**
  23351. * Legacy support, changed quaternion to rotationQuaternion
  23352. */
  23353. /**
  23354. * Legacy support, changed quaternion to rotationQuaternion
  23355. */
  23356. quaternion: Nullable<Quaternion>;
  23357. /**
  23358. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23359. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23360. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23361. * @returns true if it intersects
  23362. */
  23363. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23364. /**
  23365. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23366. * A particle is in the frustum if its bounding box intersects the frustum
  23367. * @param frustumPlanes defines the frustum to test
  23368. * @returns true if the particle is in the frustum planes
  23369. */
  23370. isInFrustum(frustumPlanes: Plane[]): boolean;
  23371. /**
  23372. * get the rotation matrix of the particle
  23373. * @hidden
  23374. */
  23375. getRotationMatrix(m: Matrix): void;
  23376. }
  23377. /**
  23378. * Represents the shape of the model used by one particle of a solid particle system.
  23379. * SPS internal tool, don't use it manually.
  23380. */
  23381. export class ModelShape {
  23382. /**
  23383. * The shape id
  23384. * @hidden
  23385. */
  23386. shapeID: number;
  23387. /**
  23388. * flat array of model positions (internal use)
  23389. * @hidden
  23390. */ shape: Vector3[];
  23391. /**
  23392. * flat array of model UVs (internal use)
  23393. * @hidden
  23394. */ shapeUV: number[];
  23395. /**
  23396. * length of the shape in the model indices array (internal use)
  23397. * @hidden
  23398. */ indicesLength: number;
  23399. /**
  23400. * Custom position function (internal use)
  23401. * @hidden
  23402. */ positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23403. /**
  23404. * Custom vertex function (internal use)
  23405. * @hidden
  23406. */ vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23407. /**
  23408. * 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.
  23409. * SPS internal tool, don't use it manually.
  23410. * @hidden
  23411. */
  23412. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  23413. }
  23414. /**
  23415. * Represents a Depth Sorted Particle in the solid particle system.
  23416. */
  23417. export class DepthSortedParticle {
  23418. /**
  23419. * Index of the particle in the "indices" array
  23420. */
  23421. ind: number;
  23422. /**
  23423. * Length of the particle shape in the "indices" array
  23424. */
  23425. indicesLength: number;
  23426. /**
  23427. * Squared distance from the particle to the camera
  23428. */
  23429. sqDistance: number;
  23430. }
  23431. }
  23432. declare module BABYLON {
  23433. /**
  23434. * Class used to store all common mesh properties
  23435. */
  23436. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23437. /** No occlusion */
  23438. static OCCLUSION_TYPE_NONE: number;
  23439. /** Occlusion set to optimisitic */
  23440. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23441. /** Occlusion set to strict */
  23442. static OCCLUSION_TYPE_STRICT: number;
  23443. /** Use an accurante occlusion algorithm */
  23444. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23445. /** Use a conservative occlusion algorithm */
  23446. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23447. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23448. * Test order :
  23449. * Is the bounding sphere outside the frustum ?
  23450. * If not, are the bounding box vertices outside the frustum ?
  23451. * It not, then the cullable object is in the frustum.
  23452. */
  23453. static readonly CULLINGSTRATEGY_STANDARD: number;
  23454. /** Culling strategy : Bounding Sphere Only.
  23455. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23456. * It's also less accurate than the standard because some not visible objects can still be selected.
  23457. * Test : is the bounding sphere outside the frustum ?
  23458. * If not, then the cullable object is in the frustum.
  23459. */
  23460. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23461. /** Culling strategy : Optimistic Inclusion.
  23462. * This in an inclusion test first, then the standard exclusion test.
  23463. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23464. * 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.
  23465. * Anyway, it's as accurate as the standard strategy.
  23466. * Test :
  23467. * Is the cullable object bounding sphere center in the frustum ?
  23468. * If not, apply the default culling strategy.
  23469. */
  23470. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23471. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23472. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23473. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23474. * 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.
  23475. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23476. * Test :
  23477. * Is the cullable object bounding sphere center in the frustum ?
  23478. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23479. */
  23480. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23481. /**
  23482. * No billboard
  23483. */
  23484. static readonly BILLBOARDMODE_NONE: number;
  23485. /** Billboard on X axis */
  23486. static readonly BILLBOARDMODE_X: number;
  23487. /** Billboard on Y axis */
  23488. static readonly BILLBOARDMODE_Y: number;
  23489. /** Billboard on Z axis */
  23490. static readonly BILLBOARDMODE_Z: number;
  23491. /** Billboard on all axes */
  23492. static readonly BILLBOARDMODE_ALL: number;
  23493. private _facetData;
  23494. /**
  23495. * The culling strategy to use to check whether the mesh must be rendered or not.
  23496. * This value can be changed at any time and will be used on the next render mesh selection.
  23497. * The possible values are :
  23498. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23499. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23500. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23501. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23502. * Please read each static variable documentation to get details about the culling process.
  23503. * */
  23504. cullingStrategy: number;
  23505. /**
  23506. * Gets the number of facets in the mesh
  23507. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23508. */
  23509. readonly facetNb: number;
  23510. /**
  23511. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23512. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23513. */
  23514. partitioningSubdivisions: number;
  23515. /**
  23516. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23517. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23518. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23519. */
  23520. partitioningBBoxRatio: number;
  23521. /**
  23522. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23523. * Works only for updatable meshes.
  23524. * Doesn't work with multi-materials
  23525. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23526. */
  23527. mustDepthSortFacets: boolean;
  23528. /**
  23529. * The location (Vector3) where the facet depth sort must be computed from.
  23530. * By default, the active camera position.
  23531. * Used only when facet depth sort is enabled
  23532. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23533. */
  23534. facetDepthSortFrom: Vector3;
  23535. /**
  23536. * gets a boolean indicating if facetData is enabled
  23537. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23538. */
  23539. readonly isFacetDataEnabled: boolean;
  23540. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  23541. /**
  23542. * An event triggered when this mesh collides with another one
  23543. */
  23544. onCollideObservable: Observable<AbstractMesh>;
  23545. private _onCollideObserver;
  23546. /** Set a function to call when this mesh collides with another one */
  23547. onCollide: () => void;
  23548. /**
  23549. * An event triggered when the collision's position changes
  23550. */
  23551. onCollisionPositionChangeObservable: Observable<Vector3>;
  23552. private _onCollisionPositionChangeObserver;
  23553. /** Set a function to call when the collision's position changes */
  23554. onCollisionPositionChange: () => void;
  23555. /**
  23556. * An event triggered when material is changed
  23557. */
  23558. onMaterialChangedObservable: Observable<AbstractMesh>;
  23559. /**
  23560. * Gets or sets the orientation for POV movement & rotation
  23561. */
  23562. definedFacingForward: boolean;
  23563. /** @hidden */ occlusionQuery: Nullable<WebGLQuery>;
  23564. private _visibility;
  23565. /**
  23566. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23567. */
  23568. /**
  23569. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23570. */
  23571. visibility: number;
  23572. /** Gets or sets the alpha index used to sort transparent meshes
  23573. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23574. */
  23575. alphaIndex: number;
  23576. /**
  23577. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23578. */
  23579. isVisible: boolean;
  23580. /**
  23581. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23582. */
  23583. isPickable: boolean;
  23584. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23585. showSubMeshesBoundingBox: boolean;
  23586. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23587. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23588. */
  23589. isBlocker: boolean;
  23590. /**
  23591. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23592. */
  23593. enablePointerMoveEvents: boolean;
  23594. /**
  23595. * Specifies the rendering group id for this mesh (0 by default)
  23596. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23597. */
  23598. renderingGroupId: number;
  23599. private _material;
  23600. /** Gets or sets current material */
  23601. material: Nullable<Material>;
  23602. private _receiveShadows;
  23603. /**
  23604. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23605. * @see http://doc.babylonjs.com/babylon101/shadows
  23606. */
  23607. receiveShadows: boolean;
  23608. /** Defines color to use when rendering outline */
  23609. outlineColor: Color3;
  23610. /** Define width to use when rendering outline */
  23611. outlineWidth: number;
  23612. /** Defines color to use when rendering overlay */
  23613. overlayColor: Color3;
  23614. /** Defines alpha to use when rendering overlay */
  23615. overlayAlpha: number;
  23616. private _hasVertexAlpha;
  23617. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23618. hasVertexAlpha: boolean;
  23619. private _useVertexColors;
  23620. /** 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) */
  23621. useVertexColors: boolean;
  23622. private _computeBonesUsingShaders;
  23623. /**
  23624. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23625. */
  23626. computeBonesUsingShaders: boolean;
  23627. private _numBoneInfluencers;
  23628. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23629. numBoneInfluencers: number;
  23630. private _applyFog;
  23631. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23632. applyFog: boolean;
  23633. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23634. useOctreeForRenderingSelection: boolean;
  23635. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  23636. useOctreeForPicking: boolean;
  23637. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  23638. useOctreeForCollisions: boolean;
  23639. private _layerMask;
  23640. /**
  23641. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  23642. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  23643. */
  23644. layerMask: number;
  23645. /**
  23646. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  23647. */
  23648. alwaysSelectAsActiveMesh: boolean;
  23649. /**
  23650. * Gets or sets the current action manager
  23651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  23652. */
  23653. actionManager: Nullable<AbstractActionManager>;
  23654. private _checkCollisions;
  23655. private _collisionMask;
  23656. private _collisionGroup;
  23657. /**
  23658. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  23659. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23660. */
  23661. ellipsoid: Vector3;
  23662. /**
  23663. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  23664. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23665. */
  23666. ellipsoidOffset: Vector3;
  23667. private _collider;
  23668. private _oldPositionForCollisions;
  23669. private _diffPositionForCollisions;
  23670. /**
  23671. * Gets or sets a collision mask used to mask collisions (default is -1).
  23672. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23673. */
  23674. collisionMask: number;
  23675. /**
  23676. * Gets or sets the current collision group mask (-1 by default).
  23677. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23678. */
  23679. collisionGroup: number;
  23680. /**
  23681. * Defines edge width used when edgesRenderer is enabled
  23682. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23683. */
  23684. edgesWidth: number;
  23685. /**
  23686. * Defines edge color used when edgesRenderer is enabled
  23687. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23688. */
  23689. edgesColor: Color4;
  23690. /** @hidden */ edgesRenderer: Nullable<IEdgesRenderer>;
  23691. /** @hidden */ masterMesh: Nullable<AbstractMesh>;
  23692. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  23693. /** @hidden */ renderId: number;
  23694. /**
  23695. * Gets or sets the list of subMeshes
  23696. * @see http://doc.babylonjs.com/how_to/multi_materials
  23697. */
  23698. subMeshes: SubMesh[];
  23699. /** @hidden */ intersectionsInProgress: AbstractMesh[];
  23700. /** @hidden */ unIndexed: boolean;
  23701. /** @hidden */ lightSources: Light[];
  23702. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  23703. /** @hidden */ waitingActions: any;
  23704. /** @hidden */ waitingFreezeWorldMatrix: Nullable<boolean>;
  23705. private _skeleton;
  23706. /** @hidden */ bonesTransformMatrices: Nullable<Float32Array>;
  23707. /**
  23708. * Gets or sets a skeleton to apply skining transformations
  23709. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23710. */
  23711. skeleton: Nullable<Skeleton>;
  23712. /**
  23713. * An event triggered when the mesh is rebuilt.
  23714. */
  23715. onRebuildObservable: Observable<AbstractMesh>;
  23716. /**
  23717. * Creates a new AbstractMesh
  23718. * @param name defines the name of the mesh
  23719. * @param scene defines the hosting scene
  23720. */
  23721. constructor(name: string, scene?: Nullable<Scene>);
  23722. /**
  23723. * Returns the string "AbstractMesh"
  23724. * @returns "AbstractMesh"
  23725. */
  23726. getClassName(): string;
  23727. /**
  23728. * Gets a string representation of the current mesh
  23729. * @param fullDetails defines a boolean indicating if full details must be included
  23730. * @returns a string representation of the current mesh
  23731. */
  23732. toString(fullDetails?: boolean): string;
  23733. /**
  23734. * @hidden
  23735. */
  23736. protected _getEffectiveParent(): Nullable<Node>;
  23737. /** @hidden */ getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  23738. /** @hidden */ rebuild(): void;
  23739. /** @hidden */ resyncLightSources(): void;
  23740. /** @hidden */ resyncLighSource(light: Light): void;
  23741. /** @hidden */ unBindEffect(): void;
  23742. /** @hidden */ removeLightSource(light: Light): void;
  23743. private _markSubMeshesAsDirty;
  23744. /** @hidden */ markSubMeshesAsLightDirty(): void;
  23745. /** @hidden */ markSubMeshesAsAttributesDirty(): void;
  23746. /** @hidden */ markSubMeshesAsMiscDirty(): void;
  23747. /**
  23748. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  23749. */
  23750. scaling: Vector3;
  23751. /**
  23752. * Returns true if the mesh is blocked. Implemented by child classes
  23753. */
  23754. readonly isBlocked: boolean;
  23755. /**
  23756. * Returns the mesh itself by default. Implemented by child classes
  23757. * @param camera defines the camera to use to pick the right LOD level
  23758. * @returns the currentAbstractMesh
  23759. */
  23760. getLOD(camera: Camera): Nullable<AbstractMesh>;
  23761. /**
  23762. * Returns 0 by default. Implemented by child classes
  23763. * @returns an integer
  23764. */
  23765. getTotalVertices(): number;
  23766. /**
  23767. * Returns a positive integer : the total number of indices in this mesh geometry.
  23768. * @returns the numner of indices or zero if the mesh has no geometry.
  23769. */
  23770. getTotalIndices(): number;
  23771. /**
  23772. * Returns null by default. Implemented by child classes
  23773. * @returns null
  23774. */
  23775. getIndices(): Nullable<IndicesArray>;
  23776. /**
  23777. * Returns the array of the requested vertex data kind. Implemented by child classes
  23778. * @param kind defines the vertex data kind to use
  23779. * @returns null
  23780. */
  23781. getVerticesData(kind: string): Nullable<FloatArray>;
  23782. /**
  23783. * Sets the vertex data of the mesh geometry for the requested `kind`.
  23784. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  23785. * Note that a new underlying VertexBuffer object is created each call.
  23786. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  23787. * @param kind defines vertex data kind:
  23788. * * VertexBuffer.PositionKind
  23789. * * VertexBuffer.UVKind
  23790. * * VertexBuffer.UV2Kind
  23791. * * VertexBuffer.UV3Kind
  23792. * * VertexBuffer.UV4Kind
  23793. * * VertexBuffer.UV5Kind
  23794. * * VertexBuffer.UV6Kind
  23795. * * VertexBuffer.ColorKind
  23796. * * VertexBuffer.MatricesIndicesKind
  23797. * * VertexBuffer.MatricesIndicesExtraKind
  23798. * * VertexBuffer.MatricesWeightsKind
  23799. * * VertexBuffer.MatricesWeightsExtraKind
  23800. * @param data defines the data source
  23801. * @param updatable defines if the data must be flagged as updatable (or static)
  23802. * @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
  23803. * @returns the current mesh
  23804. */
  23805. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23806. /**
  23807. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  23808. * If the mesh has no geometry, it is simply returned as it is.
  23809. * @param kind defines vertex data kind:
  23810. * * VertexBuffer.PositionKind
  23811. * * VertexBuffer.UVKind
  23812. * * VertexBuffer.UV2Kind
  23813. * * VertexBuffer.UV3Kind
  23814. * * VertexBuffer.UV4Kind
  23815. * * VertexBuffer.UV5Kind
  23816. * * VertexBuffer.UV6Kind
  23817. * * VertexBuffer.ColorKind
  23818. * * VertexBuffer.MatricesIndicesKind
  23819. * * VertexBuffer.MatricesIndicesExtraKind
  23820. * * VertexBuffer.MatricesWeightsKind
  23821. * * VertexBuffer.MatricesWeightsExtraKind
  23822. * @param data defines the data source
  23823. * @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
  23824. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  23825. * @returns the current mesh
  23826. */
  23827. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23828. /**
  23829. * Sets the mesh indices,
  23830. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  23831. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  23832. * @param totalVertices Defines the total number of vertices
  23833. * @returns the current mesh
  23834. */
  23835. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  23836. /**
  23837. * Gets a boolean indicating if specific vertex data is present
  23838. * @param kind defines the vertex data kind to use
  23839. * @returns true is data kind is present
  23840. */
  23841. isVerticesDataPresent(kind: string): boolean;
  23842. /**
  23843. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  23844. * @returns a BoundingInfo
  23845. */
  23846. getBoundingInfo(): BoundingInfo;
  23847. /**
  23848. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  23849. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  23850. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  23851. * @returns the current mesh
  23852. */
  23853. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  23854. /**
  23855. * Overwrite the current bounding info
  23856. * @param boundingInfo defines the new bounding info
  23857. * @returns the current mesh
  23858. */
  23859. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  23860. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  23861. readonly useBones: boolean;
  23862. /** @hidden */ preActivate(): void;
  23863. /** @hidden */ preActivateForIntermediateRendering(renderId: number): void;
  23864. /** @hidden */ activate(renderId: number): void;
  23865. /**
  23866. * Gets the current world matrix
  23867. * @returns a Matrix
  23868. */
  23869. getWorldMatrix(): Matrix;
  23870. /** @hidden */ getWorldMatrixDeterminant(): number;
  23871. /**
  23872. * Perform relative position change from the point of view of behind the front of the mesh.
  23873. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23874. * Supports definition of mesh facing forward or backward
  23875. * @param amountRight defines the distance on the right axis
  23876. * @param amountUp defines the distance on the up axis
  23877. * @param amountForward defines the distance on the forward axis
  23878. * @returns the current mesh
  23879. */
  23880. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  23881. /**
  23882. * Calculate relative position change from the point of view of behind the front of the mesh.
  23883. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23884. * Supports definition of mesh facing forward or backward
  23885. * @param amountRight defines the distance on the right axis
  23886. * @param amountUp defines the distance on the up axis
  23887. * @param amountForward defines the distance on the forward axis
  23888. * @returns the new displacement vector
  23889. */
  23890. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  23891. /**
  23892. * Perform relative rotation change from the point of view of behind the front of the mesh.
  23893. * Supports definition of mesh facing forward or backward
  23894. * @param flipBack defines the flip
  23895. * @param twirlClockwise defines the twirl
  23896. * @param tiltRight defines the tilt
  23897. * @returns the current mesh
  23898. */
  23899. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  23900. /**
  23901. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  23902. * Supports definition of mesh facing forward or backward.
  23903. * @param flipBack defines the flip
  23904. * @param twirlClockwise defines the twirl
  23905. * @param tiltRight defines the tilt
  23906. * @returns the new rotation vector
  23907. */
  23908. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  23909. /**
  23910. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  23911. * @param includeDescendants Include bounding info from descendants as well (true by default)
  23912. * @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
  23913. * @returns the new bounding vectors
  23914. */
  23915. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  23916. min: Vector3;
  23917. max: Vector3;
  23918. };
  23919. /**
  23920. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23921. * This means the mesh underlying bounding box and sphere are recomputed.
  23922. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23923. * @returns the current mesh
  23924. */
  23925. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  23926. /** @hidden */ refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  23927. /** @hidden */ getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  23928. /** @hidden */ updateBoundingInfo(): AbstractMesh;
  23929. /** @hidden */ updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  23930. /** @hidden */
  23931. protected _afterComputeWorldMatrix(): void;
  23932. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  23933. /**
  23934. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23935. * A mesh is in the frustum if its bounding box intersects the frustum
  23936. * @param frustumPlanes defines the frustum to test
  23937. * @returns true if the mesh is in the frustum planes
  23938. */
  23939. isInFrustum(frustumPlanes: Plane[]): boolean;
  23940. /**
  23941. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  23942. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  23943. * @param frustumPlanes defines the frustum to test
  23944. * @returns true if the mesh is completely in the frustum planes
  23945. */
  23946. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23947. /**
  23948. * True if the mesh intersects another mesh or a SolidParticle object
  23949. * @param mesh defines a target mesh or SolidParticle to test
  23950. * @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)
  23951. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  23952. * @returns true if there is an intersection
  23953. */
  23954. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  23955. /**
  23956. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  23957. * @param point defines the point to test
  23958. * @returns true if there is an intersection
  23959. */
  23960. intersectsPoint(point: Vector3): boolean;
  23961. /**
  23962. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  23963. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23964. */
  23965. checkCollisions: boolean;
  23966. /**
  23967. * Gets Collider object used to compute collisions (not physics)
  23968. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23969. */
  23970. readonly collider: Collider;
  23971. /**
  23972. * Move the mesh using collision engine
  23973. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23974. * @param displacement defines the requested displacement vector
  23975. * @returns the current mesh
  23976. */
  23977. moveWithCollisions(displacement: Vector3): AbstractMesh;
  23978. private _onCollisionPositionChange;
  23979. /** @hidden */ collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  23980. /** @hidden */ processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  23981. /** @hidden */ checkCollision(collider: Collider): AbstractMesh;
  23982. /** @hidden */ generatePointsArray(): boolean;
  23983. /**
  23984. * Checks if the passed Ray intersects with the mesh
  23985. * @param ray defines the ray to use
  23986. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  23987. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23988. * @returns the picking info
  23989. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  23990. */
  23991. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  23992. /**
  23993. * Clones the current mesh
  23994. * @param name defines the mesh name
  23995. * @param newParent defines the new mesh parent
  23996. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  23997. * @returns the new mesh
  23998. */
  23999. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24000. /**
  24001. * Disposes all the submeshes of the current meshnp
  24002. * @returns the current mesh
  24003. */
  24004. releaseSubMeshes(): AbstractMesh;
  24005. /**
  24006. * Releases resources associated with this abstract mesh.
  24007. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24008. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24009. */
  24010. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24011. /**
  24012. * Adds the passed mesh as a child to the current mesh
  24013. * @param mesh defines the child mesh
  24014. * @returns the current mesh
  24015. */
  24016. addChild(mesh: AbstractMesh): AbstractMesh;
  24017. /**
  24018. * Removes the passed mesh from the current mesh children list
  24019. * @param mesh defines the child mesh
  24020. * @returns the current mesh
  24021. */
  24022. removeChild(mesh: AbstractMesh): AbstractMesh;
  24023. /** @hidden */
  24024. private _initFacetData;
  24025. /**
  24026. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24027. * This method can be called within the render loop.
  24028. * 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
  24029. * @returns the current mesh
  24030. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24031. */
  24032. updateFacetData(): AbstractMesh;
  24033. /**
  24034. * Returns the facetLocalNormals array.
  24035. * The normals are expressed in the mesh local spac
  24036. * @returns an array of Vector3
  24037. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24038. */
  24039. getFacetLocalNormals(): Vector3[];
  24040. /**
  24041. * Returns the facetLocalPositions array.
  24042. * The facet positions are expressed in the mesh local space
  24043. * @returns an array of Vector3
  24044. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24045. */
  24046. getFacetLocalPositions(): Vector3[];
  24047. /**
  24048. * Returns the facetLocalPartioning array
  24049. * @returns an array of array of numbers
  24050. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24051. */
  24052. getFacetLocalPartitioning(): number[][];
  24053. /**
  24054. * Returns the i-th facet position in the world system.
  24055. * This method allocates a new Vector3 per call
  24056. * @param i defines the facet index
  24057. * @returns a new Vector3
  24058. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24059. */
  24060. getFacetPosition(i: number): Vector3;
  24061. /**
  24062. * Sets the reference Vector3 with the i-th facet position in the world system
  24063. * @param i defines the facet index
  24064. * @param ref defines the target vector
  24065. * @returns the current mesh
  24066. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24067. */
  24068. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24069. /**
  24070. * Returns the i-th facet normal in the world system.
  24071. * This method allocates a new Vector3 per call
  24072. * @param i defines the facet index
  24073. * @returns a new Vector3
  24074. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24075. */
  24076. getFacetNormal(i: number): Vector3;
  24077. /**
  24078. * Sets the reference Vector3 with the i-th facet normal in the world system
  24079. * @param i defines the facet index
  24080. * @param ref defines the target vector
  24081. * @returns the current mesh
  24082. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24083. */
  24084. getFacetNormalToRef(i: number, ref: Vector3): this;
  24085. /**
  24086. * 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)
  24087. * @param x defines x coordinate
  24088. * @param y defines y coordinate
  24089. * @param z defines z coordinate
  24090. * @returns the array of facet indexes
  24091. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24092. */
  24093. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24094. /**
  24095. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24096. * @param projected sets as the (x,y,z) world projection on the facet
  24097. * @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
  24098. * @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
  24099. * @param x defines x coordinate
  24100. * @param y defines y coordinate
  24101. * @param z defines z coordinate
  24102. * @returns the face index if found (or null instead)
  24103. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24104. */
  24105. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24106. /**
  24107. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24108. * @param projected sets as the (x,y,z) local projection on the facet
  24109. * @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
  24110. * @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
  24111. * @param x defines x coordinate
  24112. * @param y defines y coordinate
  24113. * @param z defines z coordinate
  24114. * @returns the face index if found (or null instead)
  24115. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24116. */
  24117. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24118. /**
  24119. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24120. * @returns the parameters
  24121. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24122. */
  24123. getFacetDataParameters(): any;
  24124. /**
  24125. * Disables the feature FacetData and frees the related memory
  24126. * @returns the current mesh
  24127. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24128. */
  24129. disableFacetData(): AbstractMesh;
  24130. /**
  24131. * Updates the AbstractMesh indices array
  24132. * @param indices defines the data source
  24133. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24134. * @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)
  24135. * @returns the current mesh
  24136. */
  24137. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24138. /**
  24139. * Creates new normals data for the mesh
  24140. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24141. * @returns the current mesh
  24142. */
  24143. createNormals(updatable: boolean): AbstractMesh;
  24144. /**
  24145. * Align the mesh with a normal
  24146. * @param normal defines the normal to use
  24147. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24148. * @returns the current mesh
  24149. */
  24150. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24151. /** @hidden */ checkOcclusionQuery(): boolean;
  24152. }
  24153. }
  24154. declare module BABYLON {
  24155. /**
  24156. * Interface used to define ActionEvent
  24157. */
  24158. export interface IActionEvent {
  24159. /** The mesh or sprite that triggered the action */
  24160. source: any;
  24161. /** The X mouse cursor position at the time of the event */
  24162. pointerX: number;
  24163. /** The Y mouse cursor position at the time of the event */
  24164. pointerY: number;
  24165. /** The mesh that is currently pointed at (can be null) */
  24166. meshUnderPointer: Nullable<AbstractMesh>;
  24167. /** the original (browser) event that triggered the ActionEvent */
  24168. sourceEvent?: any;
  24169. /** additional data for the event */
  24170. additionalData?: any;
  24171. }
  24172. /**
  24173. * ActionEvent is the event being sent when an action is triggered.
  24174. */
  24175. export class ActionEvent implements IActionEvent {
  24176. /** The mesh or sprite that triggered the action */
  24177. source: any;
  24178. /** The X mouse cursor position at the time of the event */
  24179. pointerX: number;
  24180. /** The Y mouse cursor position at the time of the event */
  24181. pointerY: number;
  24182. /** The mesh that is currently pointed at (can be null) */
  24183. meshUnderPointer: Nullable<AbstractMesh>;
  24184. /** the original (browser) event that triggered the ActionEvent */
  24185. sourceEvent?: any;
  24186. /** additional data for the event */
  24187. additionalData?: any;
  24188. /**
  24189. * Creates a new ActionEvent
  24190. * @param source The mesh or sprite that triggered the action
  24191. * @param pointerX The X mouse cursor position at the time of the event
  24192. * @param pointerY The Y mouse cursor position at the time of the event
  24193. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24194. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24195. * @param additionalData additional data for the event
  24196. */
  24197. constructor(
  24198. /** The mesh or sprite that triggered the action */
  24199. source: any,
  24200. /** The X mouse cursor position at the time of the event */
  24201. pointerX: number,
  24202. /** The Y mouse cursor position at the time of the event */
  24203. pointerY: number,
  24204. /** The mesh that is currently pointed at (can be null) */
  24205. meshUnderPointer: Nullable<AbstractMesh>,
  24206. /** the original (browser) event that triggered the ActionEvent */
  24207. sourceEvent?: any,
  24208. /** additional data for the event */
  24209. additionalData?: any);
  24210. /**
  24211. * Helper function to auto-create an ActionEvent from a source mesh.
  24212. * @param source The source mesh that triggered the event
  24213. * @param evt The original (browser) event
  24214. * @param additionalData additional data for the event
  24215. * @returns the new ActionEvent
  24216. */
  24217. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24218. /**
  24219. * Helper function to auto-create an ActionEvent from a source sprite
  24220. * @param source The source sprite that triggered the event
  24221. * @param scene Scene associated with the sprite
  24222. * @param evt The original (browser) event
  24223. * @param additionalData additional data for the event
  24224. * @returns the new ActionEvent
  24225. */
  24226. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24227. /**
  24228. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24229. * @param scene the scene where the event occurred
  24230. * @param evt The original (browser) event
  24231. * @returns the new ActionEvent
  24232. */
  24233. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24234. /**
  24235. * Helper function to auto-create an ActionEvent from a primitive
  24236. * @param prim defines the target primitive
  24237. * @param pointerPos defines the pointer position
  24238. * @param evt The original (browser) event
  24239. * @param additionalData additional data for the event
  24240. * @returns the new ActionEvent
  24241. */
  24242. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24243. }
  24244. }
  24245. declare module BABYLON {
  24246. /**
  24247. * Abstract class used to decouple action Manager from scene and meshes.
  24248. * Do not instantiate.
  24249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24250. */
  24251. export abstract class AbstractActionManager implements IDisposable {
  24252. /** Gets the list of active triggers */
  24253. static Triggers: {
  24254. [key: string]: number;
  24255. };
  24256. /** Gets the cursor to use when hovering items */
  24257. hoverCursor: string;
  24258. /** Gets the list of actions */
  24259. actions: IAction[];
  24260. /**
  24261. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24262. */
  24263. isRecursive: boolean;
  24264. /**
  24265. * Releases all associated resources
  24266. */
  24267. abstract dispose(): void;
  24268. /**
  24269. * Does this action manager has pointer triggers
  24270. */
  24271. abstract readonly hasPointerTriggers: boolean;
  24272. /**
  24273. * Does this action manager has pick triggers
  24274. */
  24275. abstract readonly hasPickTriggers: boolean;
  24276. /**
  24277. * Process a specific trigger
  24278. * @param trigger defines the trigger to process
  24279. * @param evt defines the event details to be processed
  24280. */
  24281. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24282. /**
  24283. * Does this action manager handles actions of any of the given triggers
  24284. * @param triggers defines the triggers to be tested
  24285. * @return a boolean indicating whether one (or more) of the triggers is handled
  24286. */
  24287. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24288. /**
  24289. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24290. * speed.
  24291. * @param triggerA defines the trigger to be tested
  24292. * @param triggerB defines the trigger to be tested
  24293. * @return a boolean indicating whether one (or more) of the triggers is handled
  24294. */
  24295. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24296. /**
  24297. * Does this action manager handles actions of a given trigger
  24298. * @param trigger defines the trigger to be tested
  24299. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24300. * @return whether the trigger is handled
  24301. */
  24302. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24303. /**
  24304. * Serialize this manager to a JSON object
  24305. * @param name defines the property name to store this manager
  24306. * @returns a JSON representation of this manager
  24307. */
  24308. abstract serialize(name: string): any;
  24309. /**
  24310. * Registers an action to this action manager
  24311. * @param action defines the action to be registered
  24312. * @return the action amended (prepared) after registration
  24313. */
  24314. abstract registerAction(action: IAction): Nullable<IAction>;
  24315. /**
  24316. * Unregisters an action to this action manager
  24317. * @param action defines the action to be unregistered
  24318. * @return a boolean indicating whether the action has been unregistered
  24319. */
  24320. abstract unregisterAction(action: IAction): Boolean;
  24321. /**
  24322. * Does exist one action manager with at least one trigger
  24323. **/
  24324. static readonly HasTriggers: boolean;
  24325. /**
  24326. * Does exist one action manager with at least one pick trigger
  24327. **/
  24328. static readonly HasPickTriggers: boolean;
  24329. /**
  24330. * Does exist one action manager that handles actions of a given trigger
  24331. * @param trigger defines the trigger to be tested
  24332. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24333. **/
  24334. static HasSpecificTrigger(trigger: number): boolean;
  24335. }
  24336. }
  24337. declare module BABYLON {
  24338. /**
  24339. * Defines how a node can be built from a string name.
  24340. */
  24341. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24342. /**
  24343. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24344. */
  24345. export class Node implements IBehaviorAware<Node> {
  24346. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24347. private static _NodeConstructors;
  24348. /**
  24349. * Add a new node constructor
  24350. * @param type defines the type name of the node to construct
  24351. * @param constructorFunc defines the constructor function
  24352. */
  24353. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24354. /**
  24355. * Returns a node constructor based on type name
  24356. * @param type defines the type name
  24357. * @param name defines the new node name
  24358. * @param scene defines the hosting scene
  24359. * @param options defines optional options to transmit to constructors
  24360. * @returns the new constructor or null
  24361. */
  24362. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24363. /**
  24364. * Gets or sets the name of the node
  24365. */
  24366. name: string;
  24367. /**
  24368. * Gets or sets the id of the node
  24369. */
  24370. id: string;
  24371. /**
  24372. * Gets or sets the unique id of the node
  24373. */
  24374. uniqueId: number;
  24375. /**
  24376. * Gets or sets a string used to store user defined state for the node
  24377. */
  24378. state: string;
  24379. /**
  24380. * Gets or sets an object used to store user defined information for the node
  24381. */
  24382. metadata: any;
  24383. /**
  24384. * For internal use only. Please do not use.
  24385. */
  24386. reservedDataStore: any;
  24387. /**
  24388. * List of inspectable custom properties (used by the Inspector)
  24389. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24390. */
  24391. inspectableCustomProperties: IInspectable[];
  24392. /**
  24393. * Gets or sets a boolean used to define if the node must be serialized
  24394. */
  24395. doNotSerialize: boolean;
  24396. /** @hidden */ isDisposed: boolean;
  24397. /**
  24398. * Gets a list of Animations associated with the node
  24399. */
  24400. animations: Animation[];
  24401. protected _ranges: {
  24402. [name: string]: Nullable<AnimationRange>;
  24403. };
  24404. /**
  24405. * Callback raised when the node is ready to be used
  24406. */
  24407. onReady: (node: Node) => void;
  24408. private _isEnabled;
  24409. private _isParentEnabled;
  24410. private _isReady;
  24411. /** @hidden */ currentRenderId: number;
  24412. private _parentUpdateId;
  24413. protected _childUpdateId: number;
  24414. /** @hidden */ waitingParentId: Nullable<string>;
  24415. /** @hidden */ scene: Scene;
  24416. /** @hidden */ cache: any;
  24417. private _parentNode;
  24418. private _children;
  24419. /** @hidden */ worldMatrix: Matrix;
  24420. /** @hidden */ worldMatrixDeterminant: number;
  24421. /** @hidden */
  24422. private _sceneRootNodesIndex;
  24423. /**
  24424. * Gets a boolean indicating if the node has been disposed
  24425. * @returns true if the node was disposed
  24426. */
  24427. isDisposed(): boolean;
  24428. /**
  24429. * Gets or sets the parent of the node (without keeping the current position in the scene)
  24430. * @see https://doc.babylonjs.com/how_to/parenting
  24431. */
  24432. parent: Nullable<Node>;
  24433. private addToSceneRootNodes;
  24434. private removeFromSceneRootNodes;
  24435. private _animationPropertiesOverride;
  24436. /**
  24437. * Gets or sets the animation properties override
  24438. */
  24439. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24440. /**
  24441. * Gets a string idenfifying the name of the class
  24442. * @returns "Node" string
  24443. */
  24444. getClassName(): string;
  24445. /** @hidden */ protected readonly _isNode: boolean;
  24446. /**
  24447. * An event triggered when the mesh is disposed
  24448. */
  24449. onDisposeObservable: Observable<Node>;
  24450. private _onDisposeObserver;
  24451. /**
  24452. * Sets a callback that will be raised when the node will be disposed
  24453. */
  24454. onDispose: () => void;
  24455. /**
  24456. * Creates a new Node
  24457. * @param name the name and id to be given to this node
  24458. * @param scene the scene this node will be added to
  24459. * @param addToRootNodes the node will be added to scene.rootNodes
  24460. */
  24461. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24462. /**
  24463. * Gets the scene of the node
  24464. * @returns a scene
  24465. */
  24466. getScene(): Scene;
  24467. /**
  24468. * Gets the engine of the node
  24469. * @returns a Engine
  24470. */
  24471. getEngine(): Engine;
  24472. private _behaviors;
  24473. /**
  24474. * Attach a behavior to the node
  24475. * @see http://doc.babylonjs.com/features/behaviour
  24476. * @param behavior defines the behavior to attach
  24477. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24478. * @returns the current Node
  24479. */
  24480. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24481. /**
  24482. * Remove an attached behavior
  24483. * @see http://doc.babylonjs.com/features/behaviour
  24484. * @param behavior defines the behavior to attach
  24485. * @returns the current Node
  24486. */
  24487. removeBehavior(behavior: Behavior<Node>): Node;
  24488. /**
  24489. * Gets the list of attached behaviors
  24490. * @see http://doc.babylonjs.com/features/behaviour
  24491. */
  24492. readonly behaviors: Behavior<Node>[];
  24493. /**
  24494. * Gets an attached behavior by name
  24495. * @param name defines the name of the behavior to look for
  24496. * @see http://doc.babylonjs.com/features/behaviour
  24497. * @returns null if behavior was not found else the requested behavior
  24498. */
  24499. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24500. /**
  24501. * Returns the latest update of the World matrix
  24502. * @returns a Matrix
  24503. */
  24504. getWorldMatrix(): Matrix;
  24505. /** @hidden */ getWorldMatrixDeterminant(): number;
  24506. /**
  24507. * Returns directly the latest state of the mesh World matrix.
  24508. * A Matrix is returned.
  24509. */
  24510. readonly worldMatrixFromCache: Matrix;
  24511. /** @hidden */ initCache(): void;
  24512. /** @hidden */
  24513. updateCache(force?: boolean): void;
  24514. /** @hidden */ getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24515. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  24516. /** @hidden */ isSynchronized(): boolean;
  24517. /** @hidden */ markSyncedWithParent(): void;
  24518. /** @hidden */
  24519. isSynchronizedWithParent(): boolean;
  24520. /** @hidden */
  24521. isSynchronized(): boolean;
  24522. /**
  24523. * Is this node ready to be used/rendered
  24524. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24525. * @return true if the node is ready
  24526. */
  24527. isReady(completeCheck?: boolean): boolean;
  24528. /**
  24529. * Is this node enabled?
  24530. * 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
  24531. * @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
  24532. * @return whether this node (and its parent) is enabled
  24533. */
  24534. isEnabled(checkAncestors?: boolean): boolean;
  24535. /** @hidden */
  24536. protected _syncParentEnabledState(): void;
  24537. /**
  24538. * Set the enabled state of this node
  24539. * @param value defines the new enabled state
  24540. */
  24541. setEnabled(value: boolean): void;
  24542. /**
  24543. * Is this node a descendant of the given node?
  24544. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24545. * @param ancestor defines the parent node to inspect
  24546. * @returns a boolean indicating if this node is a descendant of the given node
  24547. */
  24548. isDescendantOf(ancestor: Node): boolean;
  24549. /** @hidden */ getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24550. /**
  24551. * Will return all nodes that have this node as ascendant
  24552. * @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
  24553. * @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
  24554. * @return all children nodes of all types
  24555. */
  24556. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24557. /**
  24558. * Get all child-meshes of this node
  24559. * @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)
  24560. * @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
  24561. * @returns an array of AbstractMesh
  24562. */
  24563. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24564. /**
  24565. * Get all direct children of this node
  24566. * @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
  24567. * @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)
  24568. * @returns an array of Node
  24569. */
  24570. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24571. /** @hidden */ setReady(state: boolean): void;
  24572. /**
  24573. * Get an animation by name
  24574. * @param name defines the name of the animation to look for
  24575. * @returns null if not found else the requested animation
  24576. */
  24577. getAnimationByName(name: string): Nullable<Animation>;
  24578. /**
  24579. * Creates an animation range for this node
  24580. * @param name defines the name of the range
  24581. * @param from defines the starting key
  24582. * @param to defines the end key
  24583. */
  24584. createAnimationRange(name: string, from: number, to: number): void;
  24585. /**
  24586. * Delete a specific animation range
  24587. * @param name defines the name of the range to delete
  24588. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24589. */
  24590. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24591. /**
  24592. * Get an animation range by name
  24593. * @param name defines the name of the animation range to look for
  24594. * @returns null if not found else the requested animation range
  24595. */
  24596. getAnimationRange(name: string): Nullable<AnimationRange>;
  24597. /**
  24598. * Gets the list of all animation ranges defined on this node
  24599. * @returns an array
  24600. */
  24601. getAnimationRanges(): Nullable<AnimationRange>[];
  24602. /**
  24603. * Will start the animation sequence
  24604. * @param name defines the range frames for animation sequence
  24605. * @param loop defines if the animation should loop (false by default)
  24606. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24607. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24608. * @returns the object created for this animation. If range does not exist, it will return null
  24609. */
  24610. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24611. /**
  24612. * Serialize animation ranges into a JSON compatible object
  24613. * @returns serialization object
  24614. */
  24615. serializeAnimationRanges(): any;
  24616. /**
  24617. * Computes the world matrix of the node
  24618. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24619. * @returns the world matrix
  24620. */
  24621. computeWorldMatrix(force?: boolean): Matrix;
  24622. /**
  24623. * Releases resources associated with this node.
  24624. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24625. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24626. */
  24627. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24628. /**
  24629. * Parse animation range data from a serialization object and store them into a given node
  24630. * @param node defines where to store the animation ranges
  24631. * @param parsedNode defines the serialization object to read data from
  24632. * @param scene defines the hosting scene
  24633. */
  24634. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  24635. }
  24636. }
  24637. declare module BABYLON {
  24638. /**
  24639. * Class used to store any kind of animation
  24640. */
  24641. export class Animation {
  24642. /**Name of the animation */
  24643. name: string;
  24644. /**Property to animate */
  24645. targetProperty: string;
  24646. /**The frames per second of the animation */
  24647. framePerSecond: number;
  24648. /**The data type of the animation */
  24649. dataType: number;
  24650. /**The loop mode of the animation */
  24651. loopMode?: number | undefined;
  24652. /**Specifies if blending should be enabled */
  24653. enableBlending?: boolean | undefined;
  24654. /**
  24655. * Use matrix interpolation instead of using direct key value when animating matrices
  24656. */
  24657. static AllowMatricesInterpolation: boolean;
  24658. /**
  24659. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  24660. */
  24661. static AllowMatrixDecomposeForInterpolation: boolean;
  24662. /**
  24663. * Stores the key frames of the animation
  24664. */
  24665. private _keys;
  24666. /**
  24667. * Stores the easing function of the animation
  24668. */
  24669. private _easingFunction;
  24670. /**
  24671. * @hidden Internal use only
  24672. */ runtimeAnimations: RuntimeAnimation[];
  24673. /**
  24674. * The set of event that will be linked to this animation
  24675. */
  24676. private _events;
  24677. /**
  24678. * Stores an array of target property paths
  24679. */
  24680. targetPropertyPath: string[];
  24681. /**
  24682. * Stores the blending speed of the animation
  24683. */
  24684. blendingSpeed: number;
  24685. /**
  24686. * Stores the animation ranges for the animation
  24687. */
  24688. private _ranges;
  24689. /**
  24690. * @hidden Internal use
  24691. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  24692. /**
  24693. * Sets up an animation
  24694. * @param property The property to animate
  24695. * @param animationType The animation type to apply
  24696. * @param framePerSecond The frames per second of the animation
  24697. * @param easingFunction The easing function used in the animation
  24698. * @returns The created animation
  24699. */
  24700. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  24701. /**
  24702. * Create and start an animation on a node
  24703. * @param name defines the name of the global animation that will be run on all nodes
  24704. * @param node defines the root node where the animation will take place
  24705. * @param targetProperty defines property to animate
  24706. * @param framePerSecond defines the number of frame per second yo use
  24707. * @param totalFrame defines the number of frames in total
  24708. * @param from defines the initial value
  24709. * @param to defines the final value
  24710. * @param loopMode defines which loop mode you want to use (off by default)
  24711. * @param easingFunction defines the easing function to use (linear by default)
  24712. * @param onAnimationEnd defines the callback to call when animation end
  24713. * @returns the animatable created for this animation
  24714. */
  24715. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24716. /**
  24717. * Create and start an animation on a node and its descendants
  24718. * @param name defines the name of the global animation that will be run on all nodes
  24719. * @param node defines the root node where the animation will take place
  24720. * @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
  24721. * @param targetProperty defines property to animate
  24722. * @param framePerSecond defines the number of frame per second to use
  24723. * @param totalFrame defines the number of frames in total
  24724. * @param from defines the initial value
  24725. * @param to defines the final value
  24726. * @param loopMode defines which loop mode you want to use (off by default)
  24727. * @param easingFunction defines the easing function to use (linear by default)
  24728. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24729. * @returns the list of animatables created for all nodes
  24730. * @example https://www.babylonjs-playground.com/#MH0VLI
  24731. */
  24732. 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[]>;
  24733. /**
  24734. * Creates a new animation, merges it with the existing animations and starts it
  24735. * @param name Name of the animation
  24736. * @param node Node which contains the scene that begins the animations
  24737. * @param targetProperty Specifies which property to animate
  24738. * @param framePerSecond The frames per second of the animation
  24739. * @param totalFrame The total number of frames
  24740. * @param from The frame at the beginning of the animation
  24741. * @param to The frame at the end of the animation
  24742. * @param loopMode Specifies the loop mode of the animation
  24743. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  24744. * @param onAnimationEnd Callback to run once the animation is complete
  24745. * @returns Nullable animation
  24746. */
  24747. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24748. /**
  24749. * Transition property of an host to the target Value
  24750. * @param property The property to transition
  24751. * @param targetValue The target Value of the property
  24752. * @param host The object where the property to animate belongs
  24753. * @param scene Scene used to run the animation
  24754. * @param frameRate Framerate (in frame/s) to use
  24755. * @param transition The transition type we want to use
  24756. * @param duration The duration of the animation, in milliseconds
  24757. * @param onAnimationEnd Callback trigger at the end of the animation
  24758. * @returns Nullable animation
  24759. */
  24760. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  24761. /**
  24762. * Return the array of runtime animations currently using this animation
  24763. */
  24764. readonly runtimeAnimations: RuntimeAnimation[];
  24765. /**
  24766. * Specifies if any of the runtime animations are currently running
  24767. */
  24768. readonly hasRunningRuntimeAnimations: boolean;
  24769. /**
  24770. * Initializes the animation
  24771. * @param name Name of the animation
  24772. * @param targetProperty Property to animate
  24773. * @param framePerSecond The frames per second of the animation
  24774. * @param dataType The data type of the animation
  24775. * @param loopMode The loop mode of the animation
  24776. * @param enableBlending Specifies if blending should be enabled
  24777. */
  24778. constructor(
  24779. /**Name of the animation */
  24780. name: string,
  24781. /**Property to animate */
  24782. targetProperty: string,
  24783. /**The frames per second of the animation */
  24784. framePerSecond: number,
  24785. /**The data type of the animation */
  24786. dataType: number,
  24787. /**The loop mode of the animation */
  24788. loopMode?: number | undefined,
  24789. /**Specifies if blending should be enabled */
  24790. enableBlending?: boolean | undefined);
  24791. /**
  24792. * Converts the animation to a string
  24793. * @param fullDetails support for multiple levels of logging within scene loading
  24794. * @returns String form of the animation
  24795. */
  24796. toString(fullDetails?: boolean): string;
  24797. /**
  24798. * Add an event to this animation
  24799. * @param event Event to add
  24800. */
  24801. addEvent(event: AnimationEvent): void;
  24802. /**
  24803. * Remove all events found at the given frame
  24804. * @param frame The frame to remove events from
  24805. */
  24806. removeEvents(frame: number): void;
  24807. /**
  24808. * Retrieves all the events from the animation
  24809. * @returns Events from the animation
  24810. */
  24811. getEvents(): AnimationEvent[];
  24812. /**
  24813. * Creates an animation range
  24814. * @param name Name of the animation range
  24815. * @param from Starting frame of the animation range
  24816. * @param to Ending frame of the animation
  24817. */
  24818. createRange(name: string, from: number, to: number): void;
  24819. /**
  24820. * Deletes an animation range by name
  24821. * @param name Name of the animation range to delete
  24822. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  24823. */
  24824. deleteRange(name: string, deleteFrames?: boolean): void;
  24825. /**
  24826. * Gets the animation range by name, or null if not defined
  24827. * @param name Name of the animation range
  24828. * @returns Nullable animation range
  24829. */
  24830. getRange(name: string): Nullable<AnimationRange>;
  24831. /**
  24832. * Gets the key frames from the animation
  24833. * @returns The key frames of the animation
  24834. */
  24835. getKeys(): Array<IAnimationKey>;
  24836. /**
  24837. * Gets the highest frame rate of the animation
  24838. * @returns Highest frame rate of the animation
  24839. */
  24840. getHighestFrame(): number;
  24841. /**
  24842. * Gets the easing function of the animation
  24843. * @returns Easing function of the animation
  24844. */
  24845. getEasingFunction(): IEasingFunction;
  24846. /**
  24847. * Sets the easing function of the animation
  24848. * @param easingFunction A custom mathematical formula for animation
  24849. */
  24850. setEasingFunction(easingFunction: EasingFunction): void;
  24851. /**
  24852. * Interpolates a scalar linearly
  24853. * @param startValue Start value of the animation curve
  24854. * @param endValue End value of the animation curve
  24855. * @param gradient Scalar amount to interpolate
  24856. * @returns Interpolated scalar value
  24857. */
  24858. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  24859. /**
  24860. * Interpolates a scalar cubically
  24861. * @param startValue Start value of the animation curve
  24862. * @param outTangent End tangent of the animation
  24863. * @param endValue End value of the animation curve
  24864. * @param inTangent Start tangent of the animation curve
  24865. * @param gradient Scalar amount to interpolate
  24866. * @returns Interpolated scalar value
  24867. */
  24868. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  24869. /**
  24870. * Interpolates a quaternion using a spherical linear interpolation
  24871. * @param startValue Start value of the animation curve
  24872. * @param endValue End value of the animation curve
  24873. * @param gradient Scalar amount to interpolate
  24874. * @returns Interpolated quaternion value
  24875. */
  24876. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  24877. /**
  24878. * Interpolates a quaternion cubically
  24879. * @param startValue Start value of the animation curve
  24880. * @param outTangent End tangent of the animation curve
  24881. * @param endValue End value of the animation curve
  24882. * @param inTangent Start tangent of the animation curve
  24883. * @param gradient Scalar amount to interpolate
  24884. * @returns Interpolated quaternion value
  24885. */
  24886. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  24887. /**
  24888. * Interpolates a Vector3 linearl
  24889. * @param startValue Start value of the animation curve
  24890. * @param endValue End value of the animation curve
  24891. * @param gradient Scalar amount to interpolate
  24892. * @returns Interpolated scalar value
  24893. */
  24894. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  24895. /**
  24896. * Interpolates a Vector3 cubically
  24897. * @param startValue Start value of the animation curve
  24898. * @param outTangent End tangent of the animation
  24899. * @param endValue End value of the animation curve
  24900. * @param inTangent Start tangent of the animation curve
  24901. * @param gradient Scalar amount to interpolate
  24902. * @returns InterpolatedVector3 value
  24903. */
  24904. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  24905. /**
  24906. * Interpolates a Vector2 linearly
  24907. * @param startValue Start value of the animation curve
  24908. * @param endValue End value of the animation curve
  24909. * @param gradient Scalar amount to interpolate
  24910. * @returns Interpolated Vector2 value
  24911. */
  24912. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  24913. /**
  24914. * Interpolates a Vector2 cubically
  24915. * @param startValue Start value of the animation curve
  24916. * @param outTangent End tangent of the animation
  24917. * @param endValue End value of the animation curve
  24918. * @param inTangent Start tangent of the animation curve
  24919. * @param gradient Scalar amount to interpolate
  24920. * @returns Interpolated Vector2 value
  24921. */
  24922. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  24923. /**
  24924. * Interpolates a size linearly
  24925. * @param startValue Start value of the animation curve
  24926. * @param endValue End value of the animation curve
  24927. * @param gradient Scalar amount to interpolate
  24928. * @returns Interpolated Size value
  24929. */
  24930. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  24931. /**
  24932. * Interpolates a Color3 linearly
  24933. * @param startValue Start value of the animation curve
  24934. * @param endValue End value of the animation curve
  24935. * @param gradient Scalar amount to interpolate
  24936. * @returns Interpolated Color3 value
  24937. */
  24938. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  24939. /**
  24940. * @hidden Internal use only
  24941. */ getKeyValue(value: any): any;
  24942. /**
  24943. * @hidden Internal use only
  24944. */ interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  24945. /**
  24946. * Defines the function to use to interpolate matrices
  24947. * @param startValue defines the start matrix
  24948. * @param endValue defines the end matrix
  24949. * @param gradient defines the gradient between both matrices
  24950. * @param result defines an optional target matrix where to store the interpolation
  24951. * @returns the interpolated matrix
  24952. */
  24953. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  24954. /**
  24955. * Makes a copy of the animation
  24956. * @returns Cloned animation
  24957. */
  24958. clone(): Animation;
  24959. /**
  24960. * Sets the key frames of the animation
  24961. * @param values The animation key frames to set
  24962. */
  24963. setKeys(values: Array<IAnimationKey>): void;
  24964. /**
  24965. * Serializes the animation to an object
  24966. * @returns Serialized object
  24967. */
  24968. serialize(): any;
  24969. /**
  24970. * Float animation type
  24971. */
  24972. private static _ANIMATIONTYPE_FLOAT;
  24973. /**
  24974. * Vector3 animation type
  24975. */
  24976. private static _ANIMATIONTYPE_VECTOR3;
  24977. /**
  24978. * Quaternion animation type
  24979. */
  24980. private static _ANIMATIONTYPE_QUATERNION;
  24981. /**
  24982. * Matrix animation type
  24983. */
  24984. private static _ANIMATIONTYPE_MATRIX;
  24985. /**
  24986. * Color3 animation type
  24987. */
  24988. private static _ANIMATIONTYPE_COLOR3;
  24989. /**
  24990. * Vector2 animation type
  24991. */
  24992. private static _ANIMATIONTYPE_VECTOR2;
  24993. /**
  24994. * Size animation type
  24995. */
  24996. private static _ANIMATIONTYPE_SIZE;
  24997. /**
  24998. * Relative Loop Mode
  24999. */
  25000. private static _ANIMATIONLOOPMODE_RELATIVE;
  25001. /**
  25002. * Cycle Loop Mode
  25003. */
  25004. private static _ANIMATIONLOOPMODE_CYCLE;
  25005. /**
  25006. * Constant Loop Mode
  25007. */
  25008. private static _ANIMATIONLOOPMODE_CONSTANT;
  25009. /**
  25010. * Get the float animation type
  25011. */
  25012. static readonly ANIMATIONTYPE_FLOAT: number;
  25013. /**
  25014. * Get the Vector3 animation type
  25015. */
  25016. static readonly ANIMATIONTYPE_VECTOR3: number;
  25017. /**
  25018. * Get the Vector2 animation type
  25019. */
  25020. static readonly ANIMATIONTYPE_VECTOR2: number;
  25021. /**
  25022. * Get the Size animation type
  25023. */
  25024. static readonly ANIMATIONTYPE_SIZE: number;
  25025. /**
  25026. * Get the Quaternion animation type
  25027. */
  25028. static readonly ANIMATIONTYPE_QUATERNION: number;
  25029. /**
  25030. * Get the Matrix animation type
  25031. */
  25032. static readonly ANIMATIONTYPE_MATRIX: number;
  25033. /**
  25034. * Get the Color3 animation type
  25035. */
  25036. static readonly ANIMATIONTYPE_COLOR3: number;
  25037. /**
  25038. * Get the Relative Loop Mode
  25039. */
  25040. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25041. /**
  25042. * Get the Cycle Loop Mode
  25043. */
  25044. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25045. /**
  25046. * Get the Constant Loop Mode
  25047. */
  25048. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25049. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  25050. /**
  25051. * Parses an animation object and creates an animation
  25052. * @param parsedAnimation Parsed animation object
  25053. * @returns Animation object
  25054. */
  25055. static Parse(parsedAnimation: any): Animation;
  25056. /**
  25057. * Appends the serialized animations from the source animations
  25058. * @param source Source containing the animations
  25059. * @param destination Target to store the animations
  25060. */
  25061. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25062. }
  25063. }
  25064. declare module BABYLON {
  25065. /**
  25066. * Base class of all the textures in babylon.
  25067. * It groups all the common properties the materials, post process, lights... might need
  25068. * in order to make a correct use of the texture.
  25069. */
  25070. export class BaseTexture implements IAnimatable {
  25071. /**
  25072. * Default anisotropic filtering level for the application.
  25073. * It is set to 4 as a good tradeoff between perf and quality.
  25074. */
  25075. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25076. /**
  25077. * Gets or sets the unique id of the texture
  25078. */
  25079. uniqueId: number;
  25080. /**
  25081. * Define the name of the texture.
  25082. */
  25083. name: string;
  25084. /**
  25085. * Gets or sets an object used to store user defined information.
  25086. */
  25087. metadata: any;
  25088. /**
  25089. * For internal use only. Please do not use.
  25090. */
  25091. reservedDataStore: any;
  25092. private _hasAlpha;
  25093. /**
  25094. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25095. */
  25096. hasAlpha: boolean;
  25097. /**
  25098. * Defines if the alpha value should be determined via the rgb values.
  25099. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25100. */
  25101. getAlphaFromRGB: boolean;
  25102. /**
  25103. * Intensity or strength of the texture.
  25104. * It is commonly used by materials to fine tune the intensity of the texture
  25105. */
  25106. level: number;
  25107. /**
  25108. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25109. * This is part of the texture as textures usually maps to one uv set.
  25110. */
  25111. coordinatesIndex: number;
  25112. private _coordinatesMode;
  25113. /**
  25114. * How a texture is mapped.
  25115. *
  25116. * | Value | Type | Description |
  25117. * | ----- | ----------------------------------- | ----------- |
  25118. * | 0 | EXPLICIT_MODE | |
  25119. * | 1 | SPHERICAL_MODE | |
  25120. * | 2 | PLANAR_MODE | |
  25121. * | 3 | CUBIC_MODE | |
  25122. * | 4 | PROJECTION_MODE | |
  25123. * | 5 | SKYBOX_MODE | |
  25124. * | 6 | INVCUBIC_MODE | |
  25125. * | 7 | EQUIRECTANGULAR_MODE | |
  25126. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25127. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25128. */
  25129. coordinatesMode: number;
  25130. /**
  25131. * | Value | Type | Description |
  25132. * | ----- | ------------------ | ----------- |
  25133. * | 0 | CLAMP_ADDRESSMODE | |
  25134. * | 1 | WRAP_ADDRESSMODE | |
  25135. * | 2 | MIRROR_ADDRESSMODE | |
  25136. */
  25137. wrapU: number;
  25138. /**
  25139. * | Value | Type | Description |
  25140. * | ----- | ------------------ | ----------- |
  25141. * | 0 | CLAMP_ADDRESSMODE | |
  25142. * | 1 | WRAP_ADDRESSMODE | |
  25143. * | 2 | MIRROR_ADDRESSMODE | |
  25144. */
  25145. wrapV: number;
  25146. /**
  25147. * | Value | Type | Description |
  25148. * | ----- | ------------------ | ----------- |
  25149. * | 0 | CLAMP_ADDRESSMODE | |
  25150. * | 1 | WRAP_ADDRESSMODE | |
  25151. * | 2 | MIRROR_ADDRESSMODE | |
  25152. */
  25153. wrapR: number;
  25154. /**
  25155. * With compliant hardware and browser (supporting anisotropic filtering)
  25156. * this defines the level of anisotropic filtering in the texture.
  25157. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25158. */
  25159. anisotropicFilteringLevel: number;
  25160. /**
  25161. * Define if the texture is a cube texture or if false a 2d texture.
  25162. */
  25163. isCube: boolean;
  25164. /**
  25165. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25166. */
  25167. is3D: boolean;
  25168. /**
  25169. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25170. * HDR texture are usually stored in linear space.
  25171. * This only impacts the PBR and Background materials
  25172. */
  25173. gammaSpace: boolean;
  25174. /**
  25175. * Gets whether or not the texture contains RGBD data.
  25176. */
  25177. readonly isRGBD: boolean;
  25178. /**
  25179. * Is Z inverted in the texture (useful in a cube texture).
  25180. */
  25181. invertZ: boolean;
  25182. /**
  25183. * Are mip maps generated for this texture or not.
  25184. */
  25185. readonly noMipmap: boolean;
  25186. /**
  25187. * @hidden
  25188. */
  25189. lodLevelInAlpha: boolean;
  25190. /**
  25191. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25192. */
  25193. lodGenerationOffset: number;
  25194. /**
  25195. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25196. */
  25197. lodGenerationScale: number;
  25198. /**
  25199. * Define if the texture is a render target.
  25200. */
  25201. isRenderTarget: boolean;
  25202. /**
  25203. * Define the unique id of the texture in the scene.
  25204. */
  25205. readonly uid: string;
  25206. /**
  25207. * Return a string representation of the texture.
  25208. * @returns the texture as a string
  25209. */
  25210. toString(): string;
  25211. /**
  25212. * Get the class name of the texture.
  25213. * @returns "BaseTexture"
  25214. */
  25215. getClassName(): string;
  25216. /**
  25217. * Define the list of animation attached to the texture.
  25218. */
  25219. animations: Animation[];
  25220. /**
  25221. * An event triggered when the texture is disposed.
  25222. */
  25223. onDisposeObservable: Observable<BaseTexture>;
  25224. private _onDisposeObserver;
  25225. /**
  25226. * Callback triggered when the texture has been disposed.
  25227. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25228. */
  25229. onDispose: () => void;
  25230. /**
  25231. * Define the current state of the loading sequence when in delayed load mode.
  25232. */
  25233. delayLoadState: number;
  25234. private _scene;
  25235. /** @hidden */ texture: Nullable<InternalTexture>;
  25236. private _uid;
  25237. /**
  25238. * Define if the texture is preventinga material to render or not.
  25239. * If not and the texture is not ready, the engine will use a default black texture instead.
  25240. */
  25241. readonly isBlocking: boolean;
  25242. /**
  25243. * Instantiates a new BaseTexture.
  25244. * Base class of all the textures in babylon.
  25245. * It groups all the common properties the materials, post process, lights... might need
  25246. * in order to make a correct use of the texture.
  25247. * @param scene Define the scene the texture blongs to
  25248. */
  25249. constructor(scene: Nullable<Scene>);
  25250. /**
  25251. * Get the scene the texture belongs to.
  25252. * @returns the scene or null if undefined
  25253. */
  25254. getScene(): Nullable<Scene>;
  25255. /**
  25256. * Get the texture transform matrix used to offset tile the texture for istance.
  25257. * @returns the transformation matrix
  25258. */
  25259. getTextureMatrix(): Matrix;
  25260. /**
  25261. * Get the texture reflection matrix used to rotate/transform the reflection.
  25262. * @returns the reflection matrix
  25263. */
  25264. getReflectionTextureMatrix(): Matrix;
  25265. /**
  25266. * Get the underlying lower level texture from Babylon.
  25267. * @returns the insternal texture
  25268. */
  25269. getInternalTexture(): Nullable<InternalTexture>;
  25270. /**
  25271. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25272. * @returns true if ready or not blocking
  25273. */
  25274. isReadyOrNotBlocking(): boolean;
  25275. /**
  25276. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25277. * @returns true if fully ready
  25278. */
  25279. isReady(): boolean;
  25280. private _cachedSize;
  25281. /**
  25282. * Get the size of the texture.
  25283. * @returns the texture size.
  25284. */
  25285. getSize(): ISize;
  25286. /**
  25287. * Get the base size of the texture.
  25288. * It can be different from the size if the texture has been resized for POT for instance
  25289. * @returns the base size
  25290. */
  25291. getBaseSize(): ISize;
  25292. /**
  25293. * Update the sampling mode of the texture.
  25294. * Default is Trilinear mode.
  25295. *
  25296. * | Value | Type | Description |
  25297. * | ----- | ------------------ | ----------- |
  25298. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25299. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25300. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25301. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25302. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25303. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25304. * | 7 | NEAREST_LINEAR | |
  25305. * | 8 | NEAREST_NEAREST | |
  25306. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25307. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25308. * | 11 | LINEAR_LINEAR | |
  25309. * | 12 | LINEAR_NEAREST | |
  25310. *
  25311. * > _mag_: magnification filter (close to the viewer)
  25312. * > _min_: minification filter (far from the viewer)
  25313. * > _mip_: filter used between mip map levels
  25314. *@param samplingMode Define the new sampling mode of the texture
  25315. */
  25316. updateSamplingMode(samplingMode: number): void;
  25317. /**
  25318. * Scales the texture if is `canRescale()`
  25319. * @param ratio the resize factor we want to use to rescale
  25320. */
  25321. scale(ratio: number): void;
  25322. /**
  25323. * Get if the texture can rescale.
  25324. */
  25325. readonly canRescale: boolean;
  25326. /** @hidden */ getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25327. /** @hidden */ rebuild(): void;
  25328. /**
  25329. * Triggers the load sequence in delayed load mode.
  25330. */
  25331. delayLoad(): void;
  25332. /**
  25333. * Clones the texture.
  25334. * @returns the cloned texture
  25335. */
  25336. clone(): Nullable<BaseTexture>;
  25337. /**
  25338. * Get the texture underlying type (INT, FLOAT...)
  25339. */
  25340. readonly textureType: number;
  25341. /**
  25342. * Get the texture underlying format (RGB, RGBA...)
  25343. */
  25344. readonly textureFormat: number;
  25345. /**
  25346. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25347. * This will returns an RGBA array buffer containing either in values (0-255) or
  25348. * float values (0-1) depending of the underlying buffer type.
  25349. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25350. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25351. * @param buffer defines a user defined buffer to fill with data (can be null)
  25352. * @returns The Array buffer containing the pixels data.
  25353. */
  25354. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25355. /**
  25356. * Release and destroy the underlying lower level texture aka internalTexture.
  25357. */
  25358. releaseInternalTexture(): void;
  25359. /**
  25360. * Get the polynomial representation of the texture data.
  25361. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25362. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25363. */
  25364. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25365. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  25366. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  25367. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  25368. /**
  25369. * Dispose the texture and release its associated resources.
  25370. */
  25371. dispose(): void;
  25372. /**
  25373. * Serialize the texture into a JSON representation that can be parsed later on.
  25374. * @returns the JSON representation of the texture
  25375. */
  25376. serialize(): any;
  25377. /**
  25378. * Helper function to be called back once a list of texture contains only ready textures.
  25379. * @param textures Define the list of textures to wait for
  25380. * @param callback Define the callback triggered once the entire list will be ready
  25381. */
  25382. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25383. }
  25384. }
  25385. declare module BABYLON {
  25386. /**
  25387. * Uniform buffer objects.
  25388. *
  25389. * Handles blocks of uniform on the GPU.
  25390. *
  25391. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25392. *
  25393. * For more information, please refer to :
  25394. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25395. */
  25396. export class UniformBuffer {
  25397. private _engine;
  25398. private _buffer;
  25399. private _data;
  25400. private _bufferData;
  25401. private _dynamic?;
  25402. private _uniformLocations;
  25403. private _uniformSizes;
  25404. private _uniformLocationPointer;
  25405. private _needSync;
  25406. private _noUBO;
  25407. private _currentEffect;
  25408. private static _MAX_UNIFORM_SIZE;
  25409. private static _tempBuffer;
  25410. /**
  25411. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25412. * This is dynamic to allow compat with webgl 1 and 2.
  25413. * You will need to pass the name of the uniform as well as the value.
  25414. */
  25415. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25416. /**
  25417. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25418. * This is dynamic to allow compat with webgl 1 and 2.
  25419. * You will need to pass the name of the uniform as well as the value.
  25420. */
  25421. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25422. /**
  25423. * Lambda to Update a single float in a uniform buffer.
  25424. * This is dynamic to allow compat with webgl 1 and 2.
  25425. * You will need to pass the name of the uniform as well as the value.
  25426. */
  25427. updateFloat: (name: string, x: number) => void;
  25428. /**
  25429. * Lambda to Update a vec2 of float in a uniform buffer.
  25430. * This is dynamic to allow compat with webgl 1 and 2.
  25431. * You will need to pass the name of the uniform as well as the value.
  25432. */
  25433. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25434. /**
  25435. * Lambda to Update a vec3 of float in a uniform buffer.
  25436. * This is dynamic to allow compat with webgl 1 and 2.
  25437. * You will need to pass the name of the uniform as well as the value.
  25438. */
  25439. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25440. /**
  25441. * Lambda to Update a vec4 of float in a uniform buffer.
  25442. * This is dynamic to allow compat with webgl 1 and 2.
  25443. * You will need to pass the name of the uniform as well as the value.
  25444. */
  25445. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25446. /**
  25447. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25448. * This is dynamic to allow compat with webgl 1 and 2.
  25449. * You will need to pass the name of the uniform as well as the value.
  25450. */
  25451. updateMatrix: (name: string, mat: Matrix) => void;
  25452. /**
  25453. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25454. * This is dynamic to allow compat with webgl 1 and 2.
  25455. * You will need to pass the name of the uniform as well as the value.
  25456. */
  25457. updateVector3: (name: string, vector: Vector3) => void;
  25458. /**
  25459. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25460. * This is dynamic to allow compat with webgl 1 and 2.
  25461. * You will need to pass the name of the uniform as well as the value.
  25462. */
  25463. updateVector4: (name: string, vector: Vector4) => void;
  25464. /**
  25465. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25466. * This is dynamic to allow compat with webgl 1 and 2.
  25467. * You will need to pass the name of the uniform as well as the value.
  25468. */
  25469. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25470. /**
  25471. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25472. * This is dynamic to allow compat with webgl 1 and 2.
  25473. * You will need to pass the name of the uniform as well as the value.
  25474. */
  25475. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25476. /**
  25477. * Instantiates a new Uniform buffer objects.
  25478. *
  25479. * Handles blocks of uniform on the GPU.
  25480. *
  25481. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25482. *
  25483. * For more information, please refer to :
  25484. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25485. * @param engine Define the engine the buffer is associated with
  25486. * @param data Define the data contained in the buffer
  25487. * @param dynamic Define if the buffer is updatable
  25488. */
  25489. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25490. /**
  25491. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25492. * or just falling back on setUniformXXX calls.
  25493. */
  25494. readonly useUbo: boolean;
  25495. /**
  25496. * Indicates if the WebGL underlying uniform buffer is in sync
  25497. * with the javascript cache data.
  25498. */
  25499. readonly isSync: boolean;
  25500. /**
  25501. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25502. * Also, a dynamic UniformBuffer will disable cache verification and always
  25503. * update the underlying WebGL uniform buffer to the GPU.
  25504. * @returns if Dynamic, otherwise false
  25505. */
  25506. isDynamic(): boolean;
  25507. /**
  25508. * The data cache on JS side.
  25509. * @returns the underlying data as a float array
  25510. */
  25511. getData(): Float32Array;
  25512. /**
  25513. * The underlying WebGL Uniform buffer.
  25514. * @returns the webgl buffer
  25515. */
  25516. getBuffer(): Nullable<WebGLBuffer>;
  25517. /**
  25518. * std140 layout specifies how to align data within an UBO structure.
  25519. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25520. * for specs.
  25521. */
  25522. private _fillAlignment;
  25523. /**
  25524. * Adds an uniform in the buffer.
  25525. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25526. * for the layout to be correct !
  25527. * @param name Name of the uniform, as used in the uniform block in the shader.
  25528. * @param size Data size, or data directly.
  25529. */
  25530. addUniform(name: string, size: number | number[]): void;
  25531. /**
  25532. * Adds a Matrix 4x4 to the uniform buffer.
  25533. * @param name Name of the uniform, as used in the uniform block in the shader.
  25534. * @param mat A 4x4 matrix.
  25535. */
  25536. addMatrix(name: string, mat: Matrix): void;
  25537. /**
  25538. * Adds a vec2 to the uniform buffer.
  25539. * @param name Name of the uniform, as used in the uniform block in the shader.
  25540. * @param x Define the x component value of the vec2
  25541. * @param y Define the y component value of the vec2
  25542. */
  25543. addFloat2(name: string, x: number, y: number): void;
  25544. /**
  25545. * Adds a vec3 to the uniform buffer.
  25546. * @param name Name of the uniform, as used in the uniform block in the shader.
  25547. * @param x Define the x component value of the vec3
  25548. * @param y Define the y component value of the vec3
  25549. * @param z Define the z component value of the vec3
  25550. */
  25551. addFloat3(name: string, x: number, y: number, z: number): void;
  25552. /**
  25553. * Adds a vec3 to the uniform buffer.
  25554. * @param name Name of the uniform, as used in the uniform block in the shader.
  25555. * @param color Define the vec3 from a Color
  25556. */
  25557. addColor3(name: string, color: Color3): void;
  25558. /**
  25559. * Adds a vec4 to the uniform buffer.
  25560. * @param name Name of the uniform, as used in the uniform block in the shader.
  25561. * @param color Define the rgb components from a Color
  25562. * @param alpha Define the a component of the vec4
  25563. */
  25564. addColor4(name: string, color: Color3, alpha: number): void;
  25565. /**
  25566. * Adds a vec3 to the uniform buffer.
  25567. * @param name Name of the uniform, as used in the uniform block in the shader.
  25568. * @param vector Define the vec3 components from a Vector
  25569. */
  25570. addVector3(name: string, vector: Vector3): void;
  25571. /**
  25572. * Adds a Matrix 3x3 to the uniform buffer.
  25573. * @param name Name of the uniform, as used in the uniform block in the shader.
  25574. */
  25575. addMatrix3x3(name: string): void;
  25576. /**
  25577. * Adds a Matrix 2x2 to the uniform buffer.
  25578. * @param name Name of the uniform, as used in the uniform block in the shader.
  25579. */
  25580. addMatrix2x2(name: string): void;
  25581. /**
  25582. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25583. */
  25584. create(): void;
  25585. /** @hidden */ rebuild(): void;
  25586. /**
  25587. * Updates the WebGL Uniform Buffer on the GPU.
  25588. * If the `dynamic` flag is set to true, no cache comparison is done.
  25589. * Otherwise, the buffer will be updated only if the cache differs.
  25590. */
  25591. update(): void;
  25592. /**
  25593. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25594. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25595. * @param data Define the flattened data
  25596. * @param size Define the size of the data.
  25597. */
  25598. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  25599. private _updateMatrix3x3ForUniform;
  25600. private _updateMatrix3x3ForEffect;
  25601. private _updateMatrix2x2ForEffect;
  25602. private _updateMatrix2x2ForUniform;
  25603. private _updateFloatForEffect;
  25604. private _updateFloatForUniform;
  25605. private _updateFloat2ForEffect;
  25606. private _updateFloat2ForUniform;
  25607. private _updateFloat3ForEffect;
  25608. private _updateFloat3ForUniform;
  25609. private _updateFloat4ForEffect;
  25610. private _updateFloat4ForUniform;
  25611. private _updateMatrixForEffect;
  25612. private _updateMatrixForUniform;
  25613. private _updateVector3ForEffect;
  25614. private _updateVector3ForUniform;
  25615. private _updateVector4ForEffect;
  25616. private _updateVector4ForUniform;
  25617. private _updateColor3ForEffect;
  25618. private _updateColor3ForUniform;
  25619. private _updateColor4ForEffect;
  25620. private _updateColor4ForUniform;
  25621. /**
  25622. * Sets a sampler uniform on the effect.
  25623. * @param name Define the name of the sampler.
  25624. * @param texture Define the texture to set in the sampler
  25625. */
  25626. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  25627. /**
  25628. * Directly updates the value of the uniform in the cache AND on the GPU.
  25629. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25630. * @param data Define the flattened data
  25631. */
  25632. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  25633. /**
  25634. * Binds this uniform buffer to an effect.
  25635. * @param effect Define the effect to bind the buffer to
  25636. * @param name Name of the uniform block in the shader.
  25637. */
  25638. bindToEffect(effect: Effect, name: string): void;
  25639. /**
  25640. * Disposes the uniform buffer.
  25641. */
  25642. dispose(): void;
  25643. }
  25644. }
  25645. declare module BABYLON {
  25646. /**
  25647. * This represents the required contract to create a new type of texture loader.
  25648. */
  25649. export interface IInternalTextureLoader {
  25650. /**
  25651. * Defines wether the loader supports cascade loading the different faces.
  25652. */
  25653. supportCascades: boolean;
  25654. /**
  25655. * This returns if the loader support the current file information.
  25656. * @param extension defines the file extension of the file being loaded
  25657. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25658. * @param fallback defines the fallback internal texture if any
  25659. * @param isBase64 defines whether the texture is encoded as a base64
  25660. * @param isBuffer defines whether the texture data are stored as a buffer
  25661. * @returns true if the loader can load the specified file
  25662. */
  25663. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  25664. /**
  25665. * Transform the url before loading if required.
  25666. * @param rootUrl the url of the texture
  25667. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25668. * @returns the transformed texture
  25669. */
  25670. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  25671. /**
  25672. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  25673. * @param rootUrl the url of the texture
  25674. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25675. * @returns the fallback texture
  25676. */
  25677. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  25678. /**
  25679. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  25680. * @param data contains the texture data
  25681. * @param texture defines the BabylonJS internal texture
  25682. * @param createPolynomials will be true if polynomials have been requested
  25683. * @param onLoad defines the callback to trigger once the texture is ready
  25684. * @param onError defines the callback to trigger in case of error
  25685. */
  25686. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  25687. /**
  25688. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  25689. * @param data contains the texture data
  25690. * @param texture defines the BabylonJS internal texture
  25691. * @param callback defines the method to call once ready to upload
  25692. */
  25693. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  25694. }
  25695. }
  25696. declare module BABYLON {
  25697. /**
  25698. * Creation options of the multi render target texture.
  25699. */
  25700. export interface IMultiRenderTargetOptions {
  25701. /**
  25702. * Define if the texture needs to create mip maps after render.
  25703. */
  25704. generateMipMaps?: boolean;
  25705. /**
  25706. * Define the types of all the draw buffers we want to create
  25707. */
  25708. types?: number[];
  25709. /**
  25710. * Define the sampling modes of all the draw buffers we want to create
  25711. */
  25712. samplingModes?: number[];
  25713. /**
  25714. * Define if a depth buffer is required
  25715. */
  25716. generateDepthBuffer?: boolean;
  25717. /**
  25718. * Define if a stencil buffer is required
  25719. */
  25720. generateStencilBuffer?: boolean;
  25721. /**
  25722. * Define if a depth texture is required instead of a depth buffer
  25723. */
  25724. generateDepthTexture?: boolean;
  25725. /**
  25726. * Define the number of desired draw buffers
  25727. */
  25728. textureCount?: number;
  25729. /**
  25730. * Define if aspect ratio should be adapted to the texture or stay the scene one
  25731. */
  25732. doNotChangeAspectRatio?: boolean;
  25733. /**
  25734. * Define the default type of the buffers we are creating
  25735. */
  25736. defaultType?: number;
  25737. }
  25738. /**
  25739. * A multi render target, like a render target provides the ability to render to a texture.
  25740. * Unlike the render target, it can render to several draw buffers in one draw.
  25741. * This is specially interesting in deferred rendering or for any effects requiring more than
  25742. * just one color from a single pass.
  25743. */
  25744. export class MultiRenderTarget extends RenderTargetTexture {
  25745. private _internalTextures;
  25746. private _textures;
  25747. private _multiRenderTargetOptions;
  25748. /**
  25749. * Get if draw buffers are currently supported by the used hardware and browser.
  25750. */
  25751. readonly isSupported: boolean;
  25752. /**
  25753. * Get the list of textures generated by the multi render target.
  25754. */
  25755. readonly textures: Texture[];
  25756. /**
  25757. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  25758. */
  25759. readonly depthTexture: Texture;
  25760. /**
  25761. * Set the wrapping mode on U of all the textures we are rendering to.
  25762. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25763. */
  25764. wrapU: number;
  25765. /**
  25766. * Set the wrapping mode on V of all the textures we are rendering to.
  25767. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25768. */
  25769. wrapV: number;
  25770. /**
  25771. * Instantiate a new multi render target texture.
  25772. * A multi render target, like a render target provides the ability to render to a texture.
  25773. * Unlike the render target, it can render to several draw buffers in one draw.
  25774. * This is specially interesting in deferred rendering or for any effects requiring more than
  25775. * just one color from a single pass.
  25776. * @param name Define the name of the texture
  25777. * @param size Define the size of the buffers to render to
  25778. * @param count Define the number of target we are rendering into
  25779. * @param scene Define the scene the texture belongs to
  25780. * @param options Define the options used to create the multi render target
  25781. */
  25782. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  25783. /** @hidden */ rebuild(): void;
  25784. private _createInternalTextures;
  25785. private _createTextures;
  25786. /**
  25787. * Define the number of samples used if MSAA is enabled.
  25788. */
  25789. samples: number;
  25790. /**
  25791. * Resize all the textures in the multi render target.
  25792. * Be carrefull as it will recreate all the data in the new texture.
  25793. * @param size Define the new size
  25794. */
  25795. resize(size: any): void;
  25796. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25797. /**
  25798. * Dispose the render targets and their associated resources
  25799. */
  25800. dispose(): void;
  25801. /**
  25802. * Release all the underlying texture used as draw buffers.
  25803. */
  25804. releaseInternalTextures(): void;
  25805. }
  25806. }
  25807. declare module BABYLON {
  25808. /**
  25809. * Class used to work with sound analyzer using fast fourier transform (FFT)
  25810. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25811. */
  25812. export class Analyser {
  25813. /**
  25814. * Gets or sets the smoothing
  25815. * @ignorenaming
  25816. */
  25817. SMOOTHING: number;
  25818. /**
  25819. * Gets or sets the FFT table size
  25820. * @ignorenaming
  25821. */
  25822. FFT_SIZE: number;
  25823. /**
  25824. * Gets or sets the bar graph amplitude
  25825. * @ignorenaming
  25826. */
  25827. BARGRAPHAMPLITUDE: number;
  25828. /**
  25829. * Gets or sets the position of the debug canvas
  25830. * @ignorenaming
  25831. */
  25832. DEBUGCANVASPOS: {
  25833. x: number;
  25834. y: number;
  25835. };
  25836. /**
  25837. * Gets or sets the debug canvas size
  25838. * @ignorenaming
  25839. */
  25840. DEBUGCANVASSIZE: {
  25841. width: number;
  25842. height: number;
  25843. };
  25844. private _byteFreqs;
  25845. private _byteTime;
  25846. private _floatFreqs;
  25847. private _webAudioAnalyser;
  25848. private _debugCanvas;
  25849. private _debugCanvasContext;
  25850. private _scene;
  25851. private _registerFunc;
  25852. private _audioEngine;
  25853. /**
  25854. * Creates a new analyser
  25855. * @param scene defines hosting scene
  25856. */
  25857. constructor(scene: Scene);
  25858. /**
  25859. * Get the number of data values you will have to play with for the visualization
  25860. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  25861. * @returns a number
  25862. */
  25863. getFrequencyBinCount(): number;
  25864. /**
  25865. * Gets the current frequency data as a byte array
  25866. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25867. * @returns a Uint8Array
  25868. */
  25869. getByteFrequencyData(): Uint8Array;
  25870. /**
  25871. * Gets the current waveform as a byte array
  25872. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  25873. * @returns a Uint8Array
  25874. */
  25875. getByteTimeDomainData(): Uint8Array;
  25876. /**
  25877. * Gets the current frequency data as a float array
  25878. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25879. * @returns a Float32Array
  25880. */
  25881. getFloatFrequencyData(): Float32Array;
  25882. /**
  25883. * Renders the debug canvas
  25884. */
  25885. drawDebugCanvas(): void;
  25886. /**
  25887. * Stops rendering the debug canvas and removes it
  25888. */
  25889. stopDebugCanvas(): void;
  25890. /**
  25891. * Connects two audio nodes
  25892. * @param inputAudioNode defines first node to connect
  25893. * @param outputAudioNode defines second node to connect
  25894. */
  25895. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  25896. /**
  25897. * Releases all associated resources
  25898. */
  25899. dispose(): void;
  25900. }
  25901. }
  25902. declare module BABYLON {
  25903. /**
  25904. * This represents an audio engine and it is responsible
  25905. * to play, synchronize and analyse sounds throughout the application.
  25906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25907. */
  25908. export interface IAudioEngine extends IDisposable {
  25909. /**
  25910. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25911. */
  25912. readonly canUseWebAudio: boolean;
  25913. /**
  25914. * Gets the current AudioContext if available.
  25915. */
  25916. readonly audioContext: Nullable<AudioContext>;
  25917. /**
  25918. * The master gain node defines the global audio volume of your audio engine.
  25919. */
  25920. readonly masterGain: GainNode;
  25921. /**
  25922. * Gets whether or not mp3 are supported by your browser.
  25923. */
  25924. readonly isMP3supported: boolean;
  25925. /**
  25926. * Gets whether or not ogg are supported by your browser.
  25927. */
  25928. readonly isOGGsupported: boolean;
  25929. /**
  25930. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25931. * @ignoreNaming
  25932. */
  25933. WarnedWebAudioUnsupported: boolean;
  25934. /**
  25935. * Defines if the audio engine relies on a custom unlocked button.
  25936. * In this case, the embedded button will not be displayed.
  25937. */
  25938. useCustomUnlockedButton: boolean;
  25939. /**
  25940. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  25941. */
  25942. readonly unlocked: boolean;
  25943. /**
  25944. * Event raised when audio has been unlocked on the browser.
  25945. */
  25946. onAudioUnlockedObservable: Observable<AudioEngine>;
  25947. /**
  25948. * Event raised when audio has been locked on the browser.
  25949. */
  25950. onAudioLockedObservable: Observable<AudioEngine>;
  25951. /**
  25952. * Flags the audio engine in Locked state.
  25953. * This happens due to new browser policies preventing audio to autoplay.
  25954. */
  25955. lock(): void;
  25956. /**
  25957. * Unlocks the audio engine once a user action has been done on the dom.
  25958. * This is helpful to resume play once browser policies have been satisfied.
  25959. */
  25960. unlock(): void;
  25961. }
  25962. /**
  25963. * This represents the default audio engine used in babylon.
  25964. * It is responsible to play, synchronize and analyse sounds throughout the application.
  25965. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25966. */
  25967. export class AudioEngine implements IAudioEngine {
  25968. private _audioContext;
  25969. private _audioContextInitialized;
  25970. private _muteButton;
  25971. private _hostElement;
  25972. /**
  25973. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25974. */
  25975. canUseWebAudio: boolean;
  25976. /**
  25977. * The master gain node defines the global audio volume of your audio engine.
  25978. */
  25979. masterGain: GainNode;
  25980. /**
  25981. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25982. * @ignoreNaming
  25983. */
  25984. WarnedWebAudioUnsupported: boolean;
  25985. /**
  25986. * Gets whether or not mp3 are supported by your browser.
  25987. */
  25988. isMP3supported: boolean;
  25989. /**
  25990. * Gets whether or not ogg are supported by your browser.
  25991. */
  25992. isOGGsupported: boolean;
  25993. /**
  25994. * Gets whether audio has been unlocked on the device.
  25995. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  25996. * a user interaction has happened.
  25997. */
  25998. unlocked: boolean;
  25999. /**
  26000. * Defines if the audio engine relies on a custom unlocked button.
  26001. * In this case, the embedded button will not be displayed.
  26002. */
  26003. useCustomUnlockedButton: boolean;
  26004. /**
  26005. * Event raised when audio has been unlocked on the browser.
  26006. */
  26007. onAudioUnlockedObservable: Observable<AudioEngine>;
  26008. /**
  26009. * Event raised when audio has been locked on the browser.
  26010. */
  26011. onAudioLockedObservable: Observable<AudioEngine>;
  26012. /**
  26013. * Gets the current AudioContext if available.
  26014. */
  26015. readonly audioContext: Nullable<AudioContext>;
  26016. private _connectedAnalyser;
  26017. /**
  26018. * Instantiates a new audio engine.
  26019. *
  26020. * There should be only one per page as some browsers restrict the number
  26021. * of audio contexts you can create.
  26022. * @param hostElement defines the host element where to display the mute icon if necessary
  26023. */
  26024. constructor(hostElement?: Nullable<HTMLElement>);
  26025. /**
  26026. * Flags the audio engine in Locked state.
  26027. * This happens due to new browser policies preventing audio to autoplay.
  26028. */
  26029. lock(): void;
  26030. /**
  26031. * Unlocks the audio engine once a user action has been done on the dom.
  26032. * This is helpful to resume play once browser policies have been satisfied.
  26033. */
  26034. unlock(): void;
  26035. private _resumeAudioContext;
  26036. private _initializeAudioContext;
  26037. private _tryToRun;
  26038. private _triggerRunningState;
  26039. private _triggerSuspendedState;
  26040. private _displayMuteButton;
  26041. private _moveButtonToTopLeft;
  26042. private _onResize;
  26043. private _hideMuteButton;
  26044. /**
  26045. * Destroy and release the resources associated with the audio ccontext.
  26046. */
  26047. dispose(): void;
  26048. /**
  26049. * Gets the global volume sets on the master gain.
  26050. * @returns the global volume if set or -1 otherwise
  26051. */
  26052. getGlobalVolume(): number;
  26053. /**
  26054. * Sets the global volume of your experience (sets on the master gain).
  26055. * @param newVolume Defines the new global volume of the application
  26056. */
  26057. setGlobalVolume(newVolume: number): void;
  26058. /**
  26059. * Connect the audio engine to an audio analyser allowing some amazing
  26060. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26062. * @param analyser The analyser to connect to the engine
  26063. */
  26064. connectToAnalyser(analyser: Analyser): void;
  26065. }
  26066. }
  26067. declare module BABYLON {
  26068. /**
  26069. * Interface used to present a loading screen while loading a scene
  26070. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26071. */
  26072. export interface ILoadingScreen {
  26073. /**
  26074. * Function called to display the loading screen
  26075. */
  26076. displayLoadingUI: () => void;
  26077. /**
  26078. * Function called to hide the loading screen
  26079. */
  26080. hideLoadingUI: () => void;
  26081. /**
  26082. * Gets or sets the color to use for the background
  26083. */
  26084. loadingUIBackgroundColor: string;
  26085. /**
  26086. * Gets or sets the text to display while loading
  26087. */
  26088. loadingUIText: string;
  26089. }
  26090. /**
  26091. * Class used for the default loading screen
  26092. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26093. */
  26094. export class DefaultLoadingScreen implements ILoadingScreen {
  26095. private _renderingCanvas;
  26096. private _loadingText;
  26097. private _loadingDivBackgroundColor;
  26098. private _loadingDiv;
  26099. private _loadingTextDiv;
  26100. /**
  26101. * Creates a new default loading screen
  26102. * @param _renderingCanvas defines the canvas used to render the scene
  26103. * @param _loadingText defines the default text to display
  26104. * @param _loadingDivBackgroundColor defines the default background color
  26105. */
  26106. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26107. /**
  26108. * Function called to display the loading screen
  26109. */
  26110. displayLoadingUI(): void;
  26111. /**
  26112. * Function called to hide the loading screen
  26113. */
  26114. hideLoadingUI(): void;
  26115. /**
  26116. * Gets or sets the text to display while loading
  26117. */
  26118. loadingUIText: string;
  26119. /**
  26120. * Gets or sets the color to use for the background
  26121. */
  26122. loadingUIBackgroundColor: string;
  26123. private _resizeLoadingUI;
  26124. }
  26125. }
  26126. declare module BABYLON {
  26127. /**
  26128. * Settings for finer control over video usage
  26129. */
  26130. export interface VideoTextureSettings {
  26131. /**
  26132. * Applies `autoplay` to video, if specified
  26133. */
  26134. autoPlay?: boolean;
  26135. /**
  26136. * Applies `loop` to video, if specified
  26137. */
  26138. loop?: boolean;
  26139. /**
  26140. * Automatically updates internal texture from video at every frame in the render loop
  26141. */
  26142. autoUpdateTexture: boolean;
  26143. /**
  26144. * Image src displayed during the video loading or until the user interacts with the video.
  26145. */
  26146. poster?: string;
  26147. }
  26148. /**
  26149. * If you want to display a video in your scene, this is the special texture for that.
  26150. * This special texture works similar to other textures, with the exception of a few parameters.
  26151. * @see https://doc.babylonjs.com/how_to/video_texture
  26152. */
  26153. export class VideoTexture extends Texture {
  26154. /**
  26155. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26156. */
  26157. readonly autoUpdateTexture: boolean;
  26158. /**
  26159. * The video instance used by the texture internally
  26160. */
  26161. readonly video: HTMLVideoElement;
  26162. private _onUserActionRequestedObservable;
  26163. /**
  26164. * Event triggerd when a dom action is required by the user to play the video.
  26165. * This happens due to recent changes in browser policies preventing video to auto start.
  26166. */
  26167. readonly onUserActionRequestedObservable: Observable<Texture>;
  26168. private _generateMipMaps;
  26169. private _engine;
  26170. private _stillImageCaptured;
  26171. private _displayingPosterTexture;
  26172. private _settings;
  26173. private _createInternalTextureOnEvent;
  26174. /**
  26175. * Creates a video texture.
  26176. * If you want to display a video in your scene, this is the special texture for that.
  26177. * This special texture works similar to other textures, with the exception of a few parameters.
  26178. * @see https://doc.babylonjs.com/how_to/video_texture
  26179. * @param name optional name, will detect from video source, if not defined
  26180. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26181. * @param scene is obviously the current scene.
  26182. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26183. * @param invertY is false by default but can be used to invert video on Y axis
  26184. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26185. * @param settings allows finer control over video usage
  26186. */
  26187. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26188. private _getName;
  26189. private _getVideo;
  26190. private _createInternalTexture;
  26191. private reset;
  26192. /**
  26193. * @hidden Internal method to initiate `update`.
  26194. */ rebuild(): void;
  26195. /**
  26196. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26197. */
  26198. update(): void;
  26199. /**
  26200. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26201. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26202. */
  26203. updateTexture(isVisible: boolean): void;
  26204. protected _updateInternalTexture: () => void;
  26205. /**
  26206. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26207. * @param url New url.
  26208. */
  26209. updateURL(url: string): void;
  26210. /**
  26211. * Dispose the texture and release its associated resources.
  26212. */
  26213. dispose(): void;
  26214. /**
  26215. * Creates a video texture straight from a stream.
  26216. * @param scene Define the scene the texture should be created in
  26217. * @param stream Define the stream the texture should be created from
  26218. * @returns The created video texture as a promise
  26219. */
  26220. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26221. /**
  26222. * Creates a video texture straight from your WebCam video feed.
  26223. * @param scene Define the scene the texture should be created in
  26224. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26225. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26226. * @returns The created video texture as a promise
  26227. */
  26228. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26229. minWidth: number;
  26230. maxWidth: number;
  26231. minHeight: number;
  26232. maxHeight: number;
  26233. deviceId: string;
  26234. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26235. /**
  26236. * Creates a video texture straight from your WebCam video feed.
  26237. * @param scene Define the scene the texture should be created in
  26238. * @param onReady Define a callback to triggered once the texture will be ready
  26239. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26240. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26241. */
  26242. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26243. minWidth: number;
  26244. maxWidth: number;
  26245. minHeight: number;
  26246. maxHeight: number;
  26247. deviceId: string;
  26248. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26249. }
  26250. }
  26251. declare module BABYLON {
  26252. /**
  26253. * Interface for attribute information associated with buffer instanciation
  26254. */
  26255. export class InstancingAttributeInfo {
  26256. /**
  26257. * Index/offset of the attribute in the vertex shader
  26258. */
  26259. index: number;
  26260. /**
  26261. * size of the attribute, 1, 2, 3 or 4
  26262. */
  26263. attributeSize: number;
  26264. /**
  26265. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26266. * default is FLOAT
  26267. */
  26268. attribyteType: number;
  26269. /**
  26270. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26271. */
  26272. normalized: boolean;
  26273. /**
  26274. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26275. */
  26276. offset: number;
  26277. /**
  26278. * Name of the GLSL attribute, for debugging purpose only
  26279. */
  26280. attributeName: string;
  26281. }
  26282. /**
  26283. * Define options used to create a depth texture
  26284. */
  26285. export class DepthTextureCreationOptions {
  26286. /** Specifies whether or not a stencil should be allocated in the texture */
  26287. generateStencil?: boolean;
  26288. /** Specifies whether or not bilinear filtering is enable on the texture */
  26289. bilinearFiltering?: boolean;
  26290. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26291. comparisonFunction?: number;
  26292. /** Specifies if the created texture is a cube texture */
  26293. isCube?: boolean;
  26294. }
  26295. /**
  26296. * Class used to describe the capabilities of the engine relatively to the current browser
  26297. */
  26298. export class EngineCapabilities {
  26299. /** Maximum textures units per fragment shader */
  26300. maxTexturesImageUnits: number;
  26301. /** Maximum texture units per vertex shader */
  26302. maxVertexTextureImageUnits: number;
  26303. /** Maximum textures units in the entire pipeline */
  26304. maxCombinedTexturesImageUnits: number;
  26305. /** Maximum texture size */
  26306. maxTextureSize: number;
  26307. /** Maximum cube texture size */
  26308. maxCubemapTextureSize: number;
  26309. /** Maximum render texture size */
  26310. maxRenderTextureSize: number;
  26311. /** Maximum number of vertex attributes */
  26312. maxVertexAttribs: number;
  26313. /** Maximum number of varyings */
  26314. maxVaryingVectors: number;
  26315. /** Maximum number of uniforms per vertex shader */
  26316. maxVertexUniformVectors: number;
  26317. /** Maximum number of uniforms per fragment shader */
  26318. maxFragmentUniformVectors: number;
  26319. /** Defines if standard derivates (dx/dy) are supported */
  26320. standardDerivatives: boolean;
  26321. /** Defines if s3tc texture compression is supported */
  26322. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26323. /** Defines if pvrtc texture compression is supported */
  26324. pvrtc: any;
  26325. /** Defines if etc1 texture compression is supported */
  26326. etc1: any;
  26327. /** Defines if etc2 texture compression is supported */
  26328. etc2: any;
  26329. /** Defines if astc texture compression is supported */
  26330. astc: any;
  26331. /** Defines if float textures are supported */
  26332. textureFloat: boolean;
  26333. /** Defines if vertex array objects are supported */
  26334. vertexArrayObject: boolean;
  26335. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26336. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26337. /** Gets the maximum level of anisotropy supported */
  26338. maxAnisotropy: number;
  26339. /** Defines if instancing is supported */
  26340. instancedArrays: boolean;
  26341. /** Defines if 32 bits indices are supported */
  26342. uintIndices: boolean;
  26343. /** Defines if high precision shaders are supported */
  26344. highPrecisionShaderSupported: boolean;
  26345. /** Defines if depth reading in the fragment shader is supported */
  26346. fragmentDepthSupported: boolean;
  26347. /** Defines if float texture linear filtering is supported*/
  26348. textureFloatLinearFiltering: boolean;
  26349. /** Defines if rendering to float textures is supported */
  26350. textureFloatRender: boolean;
  26351. /** Defines if half float textures are supported*/
  26352. textureHalfFloat: boolean;
  26353. /** Defines if half float texture linear filtering is supported*/
  26354. textureHalfFloatLinearFiltering: boolean;
  26355. /** Defines if rendering to half float textures is supported */
  26356. textureHalfFloatRender: boolean;
  26357. /** Defines if textureLOD shader command is supported */
  26358. textureLOD: boolean;
  26359. /** Defines if draw buffers extension is supported */
  26360. drawBuffersExtension: boolean;
  26361. /** Defines if depth textures are supported */
  26362. depthTextureExtension: boolean;
  26363. /** Defines if float color buffer are supported */
  26364. colorBufferFloat: boolean;
  26365. /** Gets disjoint timer query extension (null if not supported) */
  26366. timerQuery: EXT_disjoint_timer_query;
  26367. /** Defines if timestamp can be used with timer query */
  26368. canUseTimestampForTimerQuery: boolean;
  26369. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  26370. multiview: any;
  26371. /** Function used to let the system compiles shaders in background */
  26372. parallelShaderCompile: {
  26373. COMPLETION_STATUS_KHR: number;
  26374. };
  26375. }
  26376. /** Interface defining initialization parameters for Engine class */
  26377. export interface EngineOptions extends WebGLContextAttributes {
  26378. /**
  26379. * Defines if the engine should no exceed a specified device ratio
  26380. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26381. */
  26382. limitDeviceRatio?: number;
  26383. /**
  26384. * Defines if webvr should be enabled automatically
  26385. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26386. */
  26387. autoEnableWebVR?: boolean;
  26388. /**
  26389. * Defines if webgl2 should be turned off even if supported
  26390. * @see http://doc.babylonjs.com/features/webgl2
  26391. */
  26392. disableWebGL2Support?: boolean;
  26393. /**
  26394. * Defines if webaudio should be initialized as well
  26395. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26396. */
  26397. audioEngine?: boolean;
  26398. /**
  26399. * Defines if animations should run using a deterministic lock step
  26400. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26401. */
  26402. deterministicLockstep?: boolean;
  26403. /** Defines the maximum steps to use with deterministic lock step mode */
  26404. lockstepMaxSteps?: number;
  26405. /**
  26406. * Defines that engine should ignore context lost events
  26407. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26408. */
  26409. doNotHandleContextLost?: boolean;
  26410. /**
  26411. * Defines that engine should ignore modifying touch action attribute and style
  26412. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26413. */
  26414. doNotHandleTouchAction?: boolean;
  26415. /**
  26416. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  26417. */
  26418. useHighPrecisionFloats?: boolean;
  26419. }
  26420. /**
  26421. * Defines the interface used by display changed events
  26422. */
  26423. export interface IDisplayChangedEventArgs {
  26424. /** Gets the vrDisplay object (if any) */
  26425. vrDisplay: Nullable<any>;
  26426. /** Gets a boolean indicating if webVR is supported */
  26427. vrSupported: boolean;
  26428. }
  26429. /**
  26430. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26431. */
  26432. export class Engine {
  26433. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26434. static ExceptionList: ({
  26435. key: string;
  26436. capture: string;
  26437. captureConstraint: number;
  26438. targets: string[];
  26439. } | {
  26440. key: string;
  26441. capture: null;
  26442. captureConstraint: null;
  26443. targets: string[];
  26444. })[];
  26445. /** Gets the list of created engines */
  26446. static readonly Instances: Engine[];
  26447. /**
  26448. * Gets the latest created engine
  26449. */
  26450. static readonly LastCreatedEngine: Nullable<Engine>;
  26451. /**
  26452. * Gets the latest created scene
  26453. */
  26454. static readonly LastCreatedScene: Nullable<Scene>;
  26455. /**
  26456. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26457. * @param flag defines which part of the materials must be marked as dirty
  26458. * @param predicate defines a predicate used to filter which materials should be affected
  26459. */
  26460. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26461. /**
  26462. * Hidden
  26463. */ private static _TextureLoaders: IInternalTextureLoader[];
  26464. /** Defines that alpha blending is disabled */
  26465. static readonly ALPHA_DISABLE: number;
  26466. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26467. static readonly ALPHA_ADD: number;
  26468. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26469. static readonly ALPHA_COMBINE: number;
  26470. /** Defines that alpha blending to DEST - SRC * DEST */
  26471. static readonly ALPHA_SUBTRACT: number;
  26472. /** Defines that alpha blending to SRC * DEST */
  26473. static readonly ALPHA_MULTIPLY: number;
  26474. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26475. static readonly ALPHA_MAXIMIZED: number;
  26476. /** Defines that alpha blending to SRC + DEST */
  26477. static readonly ALPHA_ONEONE: number;
  26478. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26479. static readonly ALPHA_PREMULTIPLIED: number;
  26480. /**
  26481. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26482. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26483. */
  26484. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26485. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26486. static readonly ALPHA_INTERPOLATE: number;
  26487. /**
  26488. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26489. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26490. */
  26491. static readonly ALPHA_SCREENMODE: number;
  26492. /** Defines that the ressource is not delayed*/
  26493. static readonly DELAYLOADSTATE_NONE: number;
  26494. /** Defines that the ressource was successfully delay loaded */
  26495. static readonly DELAYLOADSTATE_LOADED: number;
  26496. /** Defines that the ressource is currently delay loading */
  26497. static readonly DELAYLOADSTATE_LOADING: number;
  26498. /** Defines that the ressource is delayed and has not started loading */
  26499. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26500. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26501. static readonly NEVER: number;
  26502. /** 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 */
  26503. static readonly ALWAYS: number;
  26504. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26505. static readonly LESS: number;
  26506. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26507. static readonly EQUAL: number;
  26508. /** 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 */
  26509. static readonly LEQUAL: number;
  26510. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26511. static readonly GREATER: number;
  26512. /** 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 */
  26513. static readonly GEQUAL: number;
  26514. /** 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 */
  26515. static readonly NOTEQUAL: number;
  26516. /** Passed to stencilOperation to specify that stencil value must be kept */
  26517. static readonly KEEP: number;
  26518. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26519. static readonly REPLACE: number;
  26520. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26521. static readonly INCR: number;
  26522. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26523. static readonly DECR: number;
  26524. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26525. static readonly INVERT: number;
  26526. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26527. static readonly INCR_WRAP: number;
  26528. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26529. static readonly DECR_WRAP: number;
  26530. /** Texture is not repeating outside of 0..1 UVs */
  26531. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26532. /** Texture is repeating outside of 0..1 UVs */
  26533. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26534. /** Texture is repeating and mirrored */
  26535. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26536. /** ALPHA */
  26537. static readonly TEXTUREFORMAT_ALPHA: number;
  26538. /** LUMINANCE */
  26539. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26540. /** LUMINANCE_ALPHA */
  26541. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26542. /** RGB */
  26543. static readonly TEXTUREFORMAT_RGB: number;
  26544. /** RGBA */
  26545. static readonly TEXTUREFORMAT_RGBA: number;
  26546. /** RED */
  26547. static readonly TEXTUREFORMAT_RED: number;
  26548. /** RED (2nd reference) */
  26549. static readonly TEXTUREFORMAT_R: number;
  26550. /** RG */
  26551. static readonly TEXTUREFORMAT_RG: number;
  26552. /** RED_INTEGER */
  26553. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26554. /** RED_INTEGER (2nd reference) */
  26555. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26556. /** RG_INTEGER */
  26557. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26558. /** RGB_INTEGER */
  26559. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26560. /** RGBA_INTEGER */
  26561. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26562. /** UNSIGNED_BYTE */
  26563. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26564. /** UNSIGNED_BYTE (2nd reference) */
  26565. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26566. /** FLOAT */
  26567. static readonly TEXTURETYPE_FLOAT: number;
  26568. /** HALF_FLOAT */
  26569. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26570. /** BYTE */
  26571. static readonly TEXTURETYPE_BYTE: number;
  26572. /** SHORT */
  26573. static readonly TEXTURETYPE_SHORT: number;
  26574. /** UNSIGNED_SHORT */
  26575. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26576. /** INT */
  26577. static readonly TEXTURETYPE_INT: number;
  26578. /** UNSIGNED_INT */
  26579. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26580. /** UNSIGNED_SHORT_4_4_4_4 */
  26581. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26582. /** UNSIGNED_SHORT_5_5_5_1 */
  26583. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26584. /** UNSIGNED_SHORT_5_6_5 */
  26585. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26586. /** UNSIGNED_INT_2_10_10_10_REV */
  26587. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26588. /** UNSIGNED_INT_24_8 */
  26589. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26590. /** UNSIGNED_INT_10F_11F_11F_REV */
  26591. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26592. /** UNSIGNED_INT_5_9_9_9_REV */
  26593. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26594. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26595. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26596. /** nearest is mag = nearest and min = nearest and mip = linear */
  26597. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26598. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26599. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  26600. /** Trilinear is mag = linear and min = linear and mip = linear */
  26601. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  26602. /** nearest is mag = nearest and min = nearest and mip = linear */
  26603. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  26604. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26605. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  26606. /** Trilinear is mag = linear and min = linear and mip = linear */
  26607. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  26608. /** mag = nearest and min = nearest and mip = nearest */
  26609. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  26610. /** mag = nearest and min = linear and mip = nearest */
  26611. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  26612. /** mag = nearest and min = linear and mip = linear */
  26613. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  26614. /** mag = nearest and min = linear and mip = none */
  26615. static readonly TEXTURE_NEAREST_LINEAR: number;
  26616. /** mag = nearest and min = nearest and mip = none */
  26617. static readonly TEXTURE_NEAREST_NEAREST: number;
  26618. /** mag = linear and min = nearest and mip = nearest */
  26619. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  26620. /** mag = linear and min = nearest and mip = linear */
  26621. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  26622. /** mag = linear and min = linear and mip = none */
  26623. static readonly TEXTURE_LINEAR_LINEAR: number;
  26624. /** mag = linear and min = nearest and mip = none */
  26625. static readonly TEXTURE_LINEAR_NEAREST: number;
  26626. /** Explicit coordinates mode */
  26627. static readonly TEXTURE_EXPLICIT_MODE: number;
  26628. /** Spherical coordinates mode */
  26629. static readonly TEXTURE_SPHERICAL_MODE: number;
  26630. /** Planar coordinates mode */
  26631. static readonly TEXTURE_PLANAR_MODE: number;
  26632. /** Cubic coordinates mode */
  26633. static readonly TEXTURE_CUBIC_MODE: number;
  26634. /** Projection coordinates mode */
  26635. static readonly TEXTURE_PROJECTION_MODE: number;
  26636. /** Skybox coordinates mode */
  26637. static readonly TEXTURE_SKYBOX_MODE: number;
  26638. /** Inverse Cubic coordinates mode */
  26639. static readonly TEXTURE_INVCUBIC_MODE: number;
  26640. /** Equirectangular coordinates mode */
  26641. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  26642. /** Equirectangular Fixed coordinates mode */
  26643. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  26644. /** Equirectangular Fixed Mirrored coordinates mode */
  26645. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  26646. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26647. static readonly SCALEMODE_FLOOR: number;
  26648. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26649. static readonly SCALEMODE_NEAREST: number;
  26650. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26651. static readonly SCALEMODE_CEILING: number;
  26652. /**
  26653. * Returns the current npm package of the sdk
  26654. */
  26655. static readonly NpmPackage: string;
  26656. /**
  26657. * Returns the current version of the framework
  26658. */
  26659. static readonly Version: string;
  26660. /**
  26661. * Returns a string describing the current engine
  26662. */
  26663. readonly description: string;
  26664. /**
  26665. * Gets or sets the epsilon value used by collision engine
  26666. */
  26667. static CollisionsEpsilon: number;
  26668. /**
  26669. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  26670. */
  26671. static ShadersRepository: string;
  26672. /**
  26673. * Method called to create the default loading screen.
  26674. * This can be overriden in your own app.
  26675. * @param canvas The rendering canvas element
  26676. * @returns The loading screen
  26677. */
  26678. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  26679. /**
  26680. * Method called to create the default rescale post process on each engine.
  26681. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  26682. /**
  26683. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26684. */
  26685. forcePOTTextures: boolean;
  26686. /**
  26687. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26688. */
  26689. isFullscreen: boolean;
  26690. /**
  26691. * Gets a boolean indicating if the pointer is currently locked
  26692. */
  26693. isPointerLock: boolean;
  26694. /**
  26695. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  26696. */
  26697. cullBackFaces: boolean;
  26698. /**
  26699. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  26700. */
  26701. renderEvenInBackground: boolean;
  26702. /**
  26703. * Gets or sets a boolean indicating that cache can be kept between frames
  26704. */
  26705. preventCacheWipeBetweenFrames: boolean;
  26706. /**
  26707. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  26708. **/
  26709. enableOfflineSupport: boolean;
  26710. /**
  26711. * 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)
  26712. **/
  26713. disableManifestCheck: boolean;
  26714. /**
  26715. * Gets the list of created scenes
  26716. */
  26717. scenes: Scene[];
  26718. /**
  26719. * Event raised when a new scene is created
  26720. */
  26721. onNewSceneAddedObservable: Observable<Scene>;
  26722. /**
  26723. * Gets the list of created postprocesses
  26724. */
  26725. postProcesses: PostProcess[];
  26726. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  26727. validateShaderPrograms: boolean;
  26728. /**
  26729. * Observable event triggered each time the rendering canvas is resized
  26730. */
  26731. onResizeObservable: Observable<Engine>;
  26732. /**
  26733. * Observable event triggered each time the canvas loses focus
  26734. */
  26735. onCanvasBlurObservable: Observable<Engine>;
  26736. /**
  26737. * Observable event triggered each time the canvas gains focus
  26738. */
  26739. onCanvasFocusObservable: Observable<Engine>;
  26740. /**
  26741. * Observable event triggered each time the canvas receives pointerout event
  26742. */
  26743. onCanvasPointerOutObservable: Observable<PointerEvent>;
  26744. /**
  26745. * Observable event triggered before each texture is initialized
  26746. */
  26747. onBeforeTextureInitObservable: Observable<Texture>;
  26748. private _vrDisplay;
  26749. private _vrSupported;
  26750. private _oldSize;
  26751. private _oldHardwareScaleFactor;
  26752. private _vrExclusivePointerMode;
  26753. private _webVRInitPromise;
  26754. /**
  26755. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26756. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26757. */
  26758. readonly isInVRExclusivePointerMode: boolean;
  26759. /**
  26760. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  26761. */
  26762. disableUniformBuffers: boolean;
  26763. /** @hidden */ uniformBuffers: UniformBuffer[];
  26764. /**
  26765. * Gets a boolean indicating that the engine supports uniform buffers
  26766. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  26767. */
  26768. readonly supportsUniformBuffers: boolean;
  26769. /**
  26770. * Observable raised when the engine begins a new frame
  26771. */
  26772. onBeginFrameObservable: Observable<Engine>;
  26773. /**
  26774. * If set, will be used to request the next animation frame for the render loop
  26775. */
  26776. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  26777. /**
  26778. * Observable raised when the engine ends the current frame
  26779. */
  26780. onEndFrameObservable: Observable<Engine>;
  26781. /**
  26782. * Observable raised when the engine is about to compile a shader
  26783. */
  26784. onBeforeShaderCompilationObservable: Observable<Engine>;
  26785. /**
  26786. * Observable raised when the engine has jsut compiled a shader
  26787. */
  26788. onAfterShaderCompilationObservable: Observable<Engine>;
  26789. /** @hidden */ gl: WebGLRenderingContext;
  26790. private _renderingCanvas;
  26791. private _windowIsBackground;
  26792. private _webGLVersion;
  26793. protected _highPrecisionShadersAllowed: boolean;
  26794. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  26795. /**
  26796. * Gets a boolean indicating that only power of 2 textures are supported
  26797. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  26798. */
  26799. readonly needPOTTextures: boolean;
  26800. /** @hidden */ badOS: boolean;
  26801. /** @hidden */ badDesktopOS: boolean;
  26802. /**
  26803. * Gets or sets a value indicating if we want to disable texture binding optimization.
  26804. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  26805. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  26806. */
  26807. disableTextureBindingOptimization: boolean;
  26808. /**
  26809. * Gets the audio engine
  26810. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26811. * @ignorenaming
  26812. */
  26813. static audioEngine: IAudioEngine;
  26814. /**
  26815. * Default AudioEngine factory responsible of creating the Audio Engine.
  26816. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  26817. */
  26818. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  26819. /**
  26820. * Default offline support factory responsible of creating a tool used to store data locally.
  26821. * By default, this will create a Database object if the workload has been embedded.
  26822. */
  26823. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  26824. private _onFocus;
  26825. private _onBlur;
  26826. private _onCanvasPointerOut;
  26827. private _onCanvasBlur;
  26828. private _onCanvasFocus;
  26829. private _onFullscreenChange;
  26830. private _onPointerLockChange;
  26831. private _onVRDisplayPointerRestricted;
  26832. private _onVRDisplayPointerUnrestricted;
  26833. private _onVrDisplayConnect;
  26834. private _onVrDisplayDisconnect;
  26835. private _onVrDisplayPresentChange;
  26836. /**
  26837. * Observable signaled when VR display mode changes
  26838. */
  26839. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26840. /**
  26841. * Observable signaled when VR request present is complete
  26842. */
  26843. onVRRequestPresentComplete: Observable<boolean>;
  26844. /**
  26845. * Observable signaled when VR request present starts
  26846. */
  26847. onVRRequestPresentStart: Observable<Engine>;
  26848. private _hardwareScalingLevel;
  26849. /** @hidden */
  26850. protected _caps: EngineCapabilities;
  26851. private _pointerLockRequested;
  26852. private _isStencilEnable;
  26853. private _colorWrite;
  26854. private _loadingScreen;
  26855. /** @hidden */ drawCalls: PerfCounter;
  26856. /** @hidden */ textureCollisions: PerfCounter;
  26857. private _glVersion;
  26858. private _glRenderer;
  26859. private _glVendor;
  26860. private _videoTextureSupported;
  26861. private _renderingQueueLaunched;
  26862. private _activeRenderLoops;
  26863. private _deterministicLockstep;
  26864. private _lockstepMaxSteps;
  26865. /**
  26866. * Observable signaled when a context lost event is raised
  26867. */
  26868. onContextLostObservable: Observable<Engine>;
  26869. /**
  26870. * Observable signaled when a context restored event is raised
  26871. */
  26872. onContextRestoredObservable: Observable<Engine>;
  26873. private _onContextLost;
  26874. private _onContextRestored;
  26875. private _contextWasLost;
  26876. private _doNotHandleContextLost;
  26877. /**
  26878. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  26879. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  26880. */
  26881. doNotHandleContextLost: boolean;
  26882. private _performanceMonitor;
  26883. private _fps;
  26884. private _deltaTime;
  26885. /**
  26886. * Turn this value on if you want to pause FPS computation when in background
  26887. */
  26888. disablePerformanceMonitorInBackground: boolean;
  26889. /**
  26890. * Gets the performance monitor attached to this engine
  26891. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  26892. */
  26893. readonly performanceMonitor: PerformanceMonitor;
  26894. /**
  26895. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  26896. */
  26897. disableVertexArrayObjects: boolean;
  26898. /** @hidden */
  26899. protected _depthCullingState: _DepthCullingState;
  26900. /** @hidden */
  26901. protected _stencilState: _StencilState;
  26902. /** @hidden */
  26903. protected _alphaState: _AlphaState;
  26904. /** @hidden */
  26905. protected _alphaMode: number;
  26906. protected _internalTexturesCache: InternalTexture[];
  26907. /** @hidden */
  26908. protected _activeChannel: number;
  26909. private _currentTextureChannel;
  26910. /** @hidden */
  26911. protected _boundTexturesCache: {
  26912. [key: string]: Nullable<InternalTexture>;
  26913. };
  26914. /** @hidden */
  26915. protected _currentEffect: Nullable<Effect>;
  26916. /** @hidden */
  26917. protected _currentProgram: Nullable<WebGLProgram>;
  26918. private _compiledEffects;
  26919. private _vertexAttribArraysEnabled;
  26920. /** @hidden */
  26921. protected _cachedViewport: Nullable<Viewport>;
  26922. private _cachedVertexArrayObject;
  26923. /** @hidden */
  26924. protected _cachedVertexBuffers: any;
  26925. /** @hidden */
  26926. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  26927. /** @hidden */
  26928. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  26929. /** @hidden */
  26930. protected _currentRenderTarget: Nullable<InternalTexture>;
  26931. private _uintIndicesCurrentlySet;
  26932. private _currentBoundBuffer;
  26933. /** @hidden */
  26934. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  26935. private _currentBufferPointers;
  26936. private _currentInstanceLocations;
  26937. private _currentInstanceBuffers;
  26938. private _textureUnits;
  26939. private _firstBoundInternalTextureTracker;
  26940. private _lastBoundInternalTextureTracker;
  26941. private _workingCanvas;
  26942. private _workingContext;
  26943. private _rescalePostProcess;
  26944. private _dummyFramebuffer;
  26945. private _externalData;
  26946. private _bindedRenderFunction;
  26947. private _vaoRecordInProgress;
  26948. private _mustWipeVertexAttributes;
  26949. private _emptyTexture;
  26950. private _emptyCubeTexture;
  26951. private _emptyTexture3D;
  26952. /** @hidden */ frameHandler: number;
  26953. private _nextFreeTextureSlots;
  26954. private _maxSimultaneousTextures;
  26955. private _activeRequests;
  26956. private _texturesSupported;
  26957. private _textureFormatInUse;
  26958. /**
  26959. * Gets the list of texture formats supported
  26960. */
  26961. readonly texturesSupported: Array<string>;
  26962. /**
  26963. * Gets the list of texture formats in use
  26964. */
  26965. readonly textureFormatInUse: Nullable<string>;
  26966. /**
  26967. * Gets the current viewport
  26968. */
  26969. readonly currentViewport: Nullable<Viewport>;
  26970. /**
  26971. * Gets the default empty texture
  26972. */
  26973. readonly emptyTexture: InternalTexture;
  26974. /**
  26975. * Gets the default empty 3D texture
  26976. */
  26977. readonly emptyTexture3D: InternalTexture;
  26978. /**
  26979. * Gets the default empty cube texture
  26980. */
  26981. readonly emptyCubeTexture: InternalTexture;
  26982. /**
  26983. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  26984. */
  26985. readonly premultipliedAlpha: boolean;
  26986. /**
  26987. * Creates a new engine
  26988. * @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
  26989. * @param antialias defines enable antialiasing (default: false)
  26990. * @param options defines further options to be sent to the getContext() function
  26991. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  26992. */
  26993. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  26994. private _disableTouchAction;
  26995. private _rebuildInternalTextures;
  26996. private _rebuildEffects;
  26997. /**
  26998. * Gets a boolean indicating if all created effects are ready
  26999. * @returns true if all effects are ready
  27000. */
  27001. areAllEffectsReady(): boolean;
  27002. private _rebuildBuffers;
  27003. private _initGLContext;
  27004. /**
  27005. * Gets version of the current webGL context
  27006. */
  27007. readonly webGLVersion: number;
  27008. /**
  27009. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27010. */
  27011. readonly isStencilEnable: boolean;
  27012. private _prepareWorkingCanvas;
  27013. /**
  27014. * Reset the texture cache to empty state
  27015. */
  27016. resetTextureCache(): void;
  27017. /**
  27018. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27019. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27020. * @returns true if engine is in deterministic lock step mode
  27021. */
  27022. isDeterministicLockStep(): boolean;
  27023. /**
  27024. * Gets the max steps when engine is running in deterministic lock step
  27025. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27026. * @returns the max steps
  27027. */
  27028. getLockstepMaxSteps(): number;
  27029. /**
  27030. * Gets an object containing information about the current webGL context
  27031. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27032. */
  27033. getGlInfo(): {
  27034. vendor: string;
  27035. renderer: string;
  27036. version: string;
  27037. };
  27038. /**
  27039. * Gets current aspect ratio
  27040. * @param camera defines the camera to use to get the aspect ratio
  27041. * @param useScreen defines if screen size must be used (or the current render target if any)
  27042. * @returns a number defining the aspect ratio
  27043. */
  27044. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27045. /**
  27046. * Gets current screen aspect ratio
  27047. * @returns a number defining the aspect ratio
  27048. */
  27049. getScreenAspectRatio(): number;
  27050. /**
  27051. * Gets the current render width
  27052. * @param useScreen defines if screen size must be used (or the current render target if any)
  27053. * @returns a number defining the current render width
  27054. */
  27055. getRenderWidth(useScreen?: boolean): number;
  27056. /**
  27057. * Gets the current render height
  27058. * @param useScreen defines if screen size must be used (or the current render target if any)
  27059. * @returns a number defining the current render height
  27060. */
  27061. getRenderHeight(useScreen?: boolean): number;
  27062. /**
  27063. * Gets the HTML canvas attached with the current webGL context
  27064. * @returns a HTML canvas
  27065. */
  27066. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27067. /**
  27068. * Gets the client rect of the HTML canvas attached with the current webGL context
  27069. * @returns a client rectanglee
  27070. */
  27071. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27072. /**
  27073. * Defines the hardware scaling level.
  27074. * By default the hardware scaling level is computed from the window device ratio.
  27075. * 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.
  27076. * @param level defines the level to use
  27077. */
  27078. setHardwareScalingLevel(level: number): void;
  27079. /**
  27080. * Gets the current hardware scaling level.
  27081. * By default the hardware scaling level is computed from the window device ratio.
  27082. * 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.
  27083. * @returns a number indicating the current hardware scaling level
  27084. */
  27085. getHardwareScalingLevel(): number;
  27086. /**
  27087. * Gets the list of loaded textures
  27088. * @returns an array containing all loaded textures
  27089. */
  27090. getLoadedTexturesCache(): InternalTexture[];
  27091. /**
  27092. * Gets the object containing all engine capabilities
  27093. * @returns the EngineCapabilities object
  27094. */
  27095. getCaps(): EngineCapabilities;
  27096. /**
  27097. * Gets the current depth function
  27098. * @returns a number defining the depth function
  27099. */
  27100. getDepthFunction(): Nullable<number>;
  27101. /**
  27102. * Sets the current depth function
  27103. * @param depthFunc defines the function to use
  27104. */
  27105. setDepthFunction(depthFunc: number): void;
  27106. /**
  27107. * Sets the current depth function to GREATER
  27108. */
  27109. setDepthFunctionToGreater(): void;
  27110. /**
  27111. * Sets the current depth function to GEQUAL
  27112. */
  27113. setDepthFunctionToGreaterOrEqual(): void;
  27114. /**
  27115. * Sets the current depth function to LESS
  27116. */
  27117. setDepthFunctionToLess(): void;
  27118. private _cachedStencilBuffer;
  27119. private _cachedStencilFunction;
  27120. private _cachedStencilMask;
  27121. private _cachedStencilOperationPass;
  27122. private _cachedStencilOperationFail;
  27123. private _cachedStencilOperationDepthFail;
  27124. private _cachedStencilReference;
  27125. /**
  27126. * Caches the the state of the stencil buffer
  27127. */
  27128. cacheStencilState(): void;
  27129. /**
  27130. * Restores the state of the stencil buffer
  27131. */
  27132. restoreStencilState(): void;
  27133. /**
  27134. * Sets the current depth function to LEQUAL
  27135. */
  27136. setDepthFunctionToLessOrEqual(): void;
  27137. /**
  27138. * Gets a boolean indicating if stencil buffer is enabled
  27139. * @returns the current stencil buffer state
  27140. */
  27141. getStencilBuffer(): boolean;
  27142. /**
  27143. * Enable or disable the stencil buffer
  27144. * @param enable defines if the stencil buffer must be enabled or disabled
  27145. */
  27146. setStencilBuffer(enable: boolean): void;
  27147. /**
  27148. * Gets the current stencil mask
  27149. * @returns a number defining the new stencil mask to use
  27150. */
  27151. getStencilMask(): number;
  27152. /**
  27153. * Sets the current stencil mask
  27154. * @param mask defines the new stencil mask to use
  27155. */
  27156. setStencilMask(mask: number): void;
  27157. /**
  27158. * Gets the current stencil function
  27159. * @returns a number defining the stencil function to use
  27160. */
  27161. getStencilFunction(): number;
  27162. /**
  27163. * Gets the current stencil reference value
  27164. * @returns a number defining the stencil reference value to use
  27165. */
  27166. getStencilFunctionReference(): number;
  27167. /**
  27168. * Gets the current stencil mask
  27169. * @returns a number defining the stencil mask to use
  27170. */
  27171. getStencilFunctionMask(): number;
  27172. /**
  27173. * Sets the current stencil function
  27174. * @param stencilFunc defines the new stencil function to use
  27175. */
  27176. setStencilFunction(stencilFunc: number): void;
  27177. /**
  27178. * Sets the current stencil reference
  27179. * @param reference defines the new stencil reference to use
  27180. */
  27181. setStencilFunctionReference(reference: number): void;
  27182. /**
  27183. * Sets the current stencil mask
  27184. * @param mask defines the new stencil mask to use
  27185. */
  27186. setStencilFunctionMask(mask: number): void;
  27187. /**
  27188. * Gets the current stencil operation when stencil fails
  27189. * @returns a number defining stencil operation to use when stencil fails
  27190. */
  27191. getStencilOperationFail(): number;
  27192. /**
  27193. * Gets the current stencil operation when depth fails
  27194. * @returns a number defining stencil operation to use when depth fails
  27195. */
  27196. getStencilOperationDepthFail(): number;
  27197. /**
  27198. * Gets the current stencil operation when stencil passes
  27199. * @returns a number defining stencil operation to use when stencil passes
  27200. */
  27201. getStencilOperationPass(): number;
  27202. /**
  27203. * Sets the stencil operation to use when stencil fails
  27204. * @param operation defines the stencil operation to use when stencil fails
  27205. */
  27206. setStencilOperationFail(operation: number): void;
  27207. /**
  27208. * Sets the stencil operation to use when depth fails
  27209. * @param operation defines the stencil operation to use when depth fails
  27210. */
  27211. setStencilOperationDepthFail(operation: number): void;
  27212. /**
  27213. * Sets the stencil operation to use when stencil passes
  27214. * @param operation defines the stencil operation to use when stencil passes
  27215. */
  27216. setStencilOperationPass(operation: number): void;
  27217. /**
  27218. * Sets a boolean indicating if the dithering state is enabled or disabled
  27219. * @param value defines the dithering state
  27220. */
  27221. setDitheringState(value: boolean): void;
  27222. /**
  27223. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27224. * @param value defines the rasterizer state
  27225. */
  27226. setRasterizerState(value: boolean): void;
  27227. /**
  27228. * stop executing a render loop function and remove it from the execution array
  27229. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27230. */
  27231. stopRenderLoop(renderFunction?: () => void): void;
  27232. /** @hidden */ renderLoop(): void;
  27233. /**
  27234. * Register and execute a render loop. The engine can have more than one render function
  27235. * @param renderFunction defines the function to continuously execute
  27236. */
  27237. runRenderLoop(renderFunction: () => void): void;
  27238. /**
  27239. * Toggle full screen mode
  27240. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27241. */
  27242. switchFullscreen(requestPointerLock: boolean): void;
  27243. /**
  27244. * Enters full screen mode
  27245. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27246. */
  27247. enterFullscreen(requestPointerLock: boolean): void;
  27248. /**
  27249. * Exits full screen mode
  27250. */
  27251. exitFullscreen(): void;
  27252. /**
  27253. * Clear the current render buffer or the current render target (if any is set up)
  27254. * @param color defines the color to use
  27255. * @param backBuffer defines if the back buffer must be cleared
  27256. * @param depth defines if the depth buffer must be cleared
  27257. * @param stencil defines if the stencil buffer must be cleared
  27258. */
  27259. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27260. /**
  27261. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27262. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27263. * @param y defines the y-coordinate of the corner of the clear rectangle
  27264. * @param width defines the width of the clear rectangle
  27265. * @param height defines the height of the clear rectangle
  27266. * @param clearColor defines the clear color
  27267. */
  27268. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27269. /**
  27270. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27271. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27272. * @param y defines the y-coordinate of the corner of the clear rectangle
  27273. * @param width defines the width of the clear rectangle
  27274. * @param height defines the height of the clear rectangle
  27275. */
  27276. enableScissor(x: number, y: number, width: number, height: number): void;
  27277. /**
  27278. * Disable previously set scissor test rectangle
  27279. */
  27280. disableScissor(): void;
  27281. private _viewportCached;
  27282. /** @hidden */ viewport(x: number, y: number, width: number, height: number): void;
  27283. /**
  27284. * Set the WebGL's viewport
  27285. * @param viewport defines the viewport element to be used
  27286. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27287. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27288. */
  27289. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27290. /**
  27291. * Directly set the WebGL Viewport
  27292. * @param x defines the x coordinate of the viewport (in screen space)
  27293. * @param y defines the y coordinate of the viewport (in screen space)
  27294. * @param width defines the width of the viewport (in screen space)
  27295. * @param height defines the height of the viewport (in screen space)
  27296. * @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
  27297. */
  27298. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27299. /**
  27300. * Begin a new frame
  27301. */
  27302. beginFrame(): void;
  27303. /**
  27304. * Enf the current frame
  27305. */
  27306. endFrame(): void;
  27307. /**
  27308. * Resize the view according to the canvas' size
  27309. */
  27310. resize(): void;
  27311. /**
  27312. * Force a specific size of the canvas
  27313. * @param width defines the new canvas' width
  27314. * @param height defines the new canvas' height
  27315. */
  27316. setSize(width: number, height: number): void;
  27317. /**
  27318. * Gets a boolean indicating if a webVR device was detected
  27319. * @returns true if a webVR device was detected
  27320. */
  27321. isVRDevicePresent(): boolean;
  27322. /**
  27323. * Gets the current webVR device
  27324. * @returns the current webVR device (or null)
  27325. */
  27326. getVRDevice(): any;
  27327. /**
  27328. * Initializes a webVR display and starts listening to display change events
  27329. * The onVRDisplayChangedObservable will be notified upon these changes
  27330. * @returns The onVRDisplayChangedObservable
  27331. */
  27332. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27333. /**
  27334. * Initializes a webVR display and starts listening to display change events
  27335. * The onVRDisplayChangedObservable will be notified upon these changes
  27336. * @returns A promise containing a VRDisplay and if vr is supported
  27337. */
  27338. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27339. /**
  27340. * Call this function to switch to webVR mode
  27341. * Will do nothing if webVR is not supported or if there is no webVR device
  27342. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27343. */
  27344. enableVR(): void;
  27345. /**
  27346. * Call this function to leave webVR mode
  27347. * Will do nothing if webVR is not supported or if there is no webVR device
  27348. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27349. */
  27350. disableVR(): void;
  27351. private _onVRFullScreenTriggered;
  27352. private _getVRDisplaysAsync;
  27353. /**
  27354. * Binds the frame buffer to the specified texture.
  27355. * @param texture The texture to render to or null for the default canvas
  27356. * @param faceIndex The face of the texture to render to in case of cube texture
  27357. * @param requiredWidth The width of the target to render to
  27358. * @param requiredHeight The height of the target to render to
  27359. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27360. * @param depthStencilTexture The depth stencil texture to use to render
  27361. * @param lodLevel defines le lod level to bind to the frame buffer
  27362. */
  27363. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27364. private bindUnboundFramebuffer;
  27365. /**
  27366. * Unbind the current render target texture from the webGL context
  27367. * @param texture defines the render target texture to unbind
  27368. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27369. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27370. */
  27371. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27372. /**
  27373. * Unbind a list of render target textures from the webGL context
  27374. * This is used only when drawBuffer extension or webGL2 are active
  27375. * @param textures defines the render target textures to unbind
  27376. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27377. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27378. */
  27379. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27380. /**
  27381. * Force the mipmap generation for the given render target texture
  27382. * @param texture defines the render target texture to use
  27383. */
  27384. generateMipMapsForCubemap(texture: InternalTexture): void;
  27385. /**
  27386. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27387. */
  27388. flushFramebuffer(): void;
  27389. /**
  27390. * Unbind the current render target and bind the default framebuffer
  27391. */
  27392. restoreDefaultFramebuffer(): void;
  27393. /**
  27394. * Create an uniform buffer
  27395. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27396. * @param elements defines the content of the uniform buffer
  27397. * @returns the webGL uniform buffer
  27398. */
  27399. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27400. /**
  27401. * Create a dynamic uniform buffer
  27402. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27403. * @param elements defines the content of the uniform buffer
  27404. * @returns the webGL uniform buffer
  27405. */
  27406. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27407. /**
  27408. * Update an existing uniform buffer
  27409. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27410. * @param uniformBuffer defines the target uniform buffer
  27411. * @param elements defines the content to update
  27412. * @param offset defines the offset in the uniform buffer where update should start
  27413. * @param count defines the size of the data to update
  27414. */
  27415. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27416. private _resetVertexBufferBinding;
  27417. /**
  27418. * Creates a vertex buffer
  27419. * @param data the data for the vertex buffer
  27420. * @returns the new WebGL static buffer
  27421. */
  27422. createVertexBuffer(data: DataArray): WebGLBuffer;
  27423. /**
  27424. * Creates a dynamic vertex buffer
  27425. * @param data the data for the dynamic vertex buffer
  27426. * @returns the new WebGL dynamic buffer
  27427. */
  27428. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27429. /**
  27430. * Update a dynamic index buffer
  27431. * @param indexBuffer defines the target index buffer
  27432. * @param indices defines the data to update
  27433. * @param offset defines the offset in the target index buffer where update should start
  27434. */
  27435. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27436. /**
  27437. * Updates a dynamic vertex buffer.
  27438. * @param vertexBuffer the vertex buffer to update
  27439. * @param data the data used to update the vertex buffer
  27440. * @param byteOffset the byte offset of the data
  27441. * @param byteLength the byte length of the data
  27442. */
  27443. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27444. private _resetIndexBufferBinding;
  27445. /**
  27446. * Creates a new index buffer
  27447. * @param indices defines the content of the index buffer
  27448. * @param updatable defines if the index buffer must be updatable
  27449. * @returns a new webGL buffer
  27450. */
  27451. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27452. /**
  27453. * Bind a webGL buffer to the webGL context
  27454. * @param buffer defines the buffer to bind
  27455. */
  27456. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27457. /**
  27458. * Bind an uniform buffer to the current webGL context
  27459. * @param buffer defines the buffer to bind
  27460. */
  27461. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27462. /**
  27463. * Bind a buffer to the current webGL context at a given location
  27464. * @param buffer defines the buffer to bind
  27465. * @param location defines the index where to bind the buffer
  27466. */
  27467. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27468. /**
  27469. * Bind a specific block at a given index in a specific shader program
  27470. * @param shaderProgram defines the shader program
  27471. * @param blockName defines the block name
  27472. * @param index defines the index where to bind the block
  27473. */
  27474. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27475. private bindIndexBuffer;
  27476. private bindBuffer;
  27477. /**
  27478. * update the bound buffer with the given data
  27479. * @param data defines the data to update
  27480. */
  27481. updateArrayBuffer(data: Float32Array): void;
  27482. private _vertexAttribPointer;
  27483. private _bindIndexBufferWithCache;
  27484. private _bindVertexBuffersAttributes;
  27485. /**
  27486. * Records a vertex array object
  27487. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27488. * @param vertexBuffers defines the list of vertex buffers to store
  27489. * @param indexBuffer defines the index buffer to store
  27490. * @param effect defines the effect to store
  27491. * @returns the new vertex array object
  27492. */
  27493. recordVertexArrayObject(vertexBuffers: {
  27494. [key: string]: VertexBuffer;
  27495. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27496. /**
  27497. * Bind a specific vertex array object
  27498. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27499. * @param vertexArrayObject defines the vertex array object to bind
  27500. * @param indexBuffer defines the index buffer to bind
  27501. */
  27502. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27503. /**
  27504. * Bind webGl buffers directly to the webGL context
  27505. * @param vertexBuffer defines the vertex buffer to bind
  27506. * @param indexBuffer defines the index buffer to bind
  27507. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27508. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27509. * @param effect defines the effect associated with the vertex buffer
  27510. */
  27511. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27512. private _unbindVertexArrayObject;
  27513. /**
  27514. * Bind a list of vertex buffers to the webGL context
  27515. * @param vertexBuffers defines the list of vertex buffers to bind
  27516. * @param indexBuffer defines the index buffer to bind
  27517. * @param effect defines the effect associated with the vertex buffers
  27518. */
  27519. bindBuffers(vertexBuffers: {
  27520. [key: string]: Nullable<VertexBuffer>;
  27521. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27522. /**
  27523. * Unbind all instance attributes
  27524. */
  27525. unbindInstanceAttributes(): void;
  27526. /**
  27527. * Release and free the memory of a vertex array object
  27528. * @param vao defines the vertex array object to delete
  27529. */
  27530. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27531. /** @hidden */ releaseBuffer(buffer: WebGLBuffer): boolean;
  27532. /**
  27533. * Creates a webGL buffer to use with instanciation
  27534. * @param capacity defines the size of the buffer
  27535. * @returns the webGL buffer
  27536. */
  27537. createInstancesBuffer(capacity: number): WebGLBuffer;
  27538. /**
  27539. * Delete a webGL buffer used with instanciation
  27540. * @param buffer defines the webGL buffer to delete
  27541. */
  27542. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27543. /**
  27544. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27545. * @param instancesBuffer defines the webGL buffer to update and bind
  27546. * @param data defines the data to store in the buffer
  27547. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27548. */
  27549. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27550. /**
  27551. * Apply all cached states (depth, culling, stencil and alpha)
  27552. */
  27553. applyStates(): void;
  27554. /**
  27555. * Send a draw order
  27556. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27557. * @param indexStart defines the starting index
  27558. * @param indexCount defines the number of index to draw
  27559. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27560. */
  27561. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27562. /**
  27563. * Draw a list of points
  27564. * @param verticesStart defines the index of first vertex to draw
  27565. * @param verticesCount defines the count of vertices to draw
  27566. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27567. */
  27568. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27569. /**
  27570. * Draw a list of unindexed primitives
  27571. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27572. * @param verticesStart defines the index of first vertex to draw
  27573. * @param verticesCount defines the count of vertices to draw
  27574. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27575. */
  27576. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27577. /**
  27578. * Draw a list of indexed primitives
  27579. * @param fillMode defines the primitive to use
  27580. * @param indexStart defines the starting index
  27581. * @param indexCount defines the number of index to draw
  27582. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27583. */
  27584. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27585. /**
  27586. * Draw a list of unindexed primitives
  27587. * @param fillMode defines the primitive to use
  27588. * @param verticesStart defines the index of first vertex to draw
  27589. * @param verticesCount defines the count of vertices to draw
  27590. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27591. */
  27592. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27593. private _drawMode;
  27594. /** @hidden */ releaseEffect(effect: Effect): void;
  27595. /** @hidden */ deleteProgram(program: WebGLProgram): void;
  27596. /**
  27597. * Create a new effect (used to store vertex/fragment shaders)
  27598. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27599. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27600. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27601. * @param samplers defines an array of string used to represent textures
  27602. * @param defines defines the string containing the defines to use to compile the shaders
  27603. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27604. * @param onCompiled defines a function to call when the effect creation is successful
  27605. * @param onError defines a function to call when the effect creation has failed
  27606. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27607. * @returns the new Effect
  27608. */
  27609. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  27610. private _compileShader;
  27611. private _compileRawShader;
  27612. /**
  27613. * Directly creates a webGL program
  27614. * @param vertexCode defines the vertex shader code to use
  27615. * @param fragmentCode defines the fragment shader code to use
  27616. * @param context defines the webGL context to use (if not set, the current one will be used)
  27617. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27618. * @returns the new webGL program
  27619. */
  27620. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27621. /**
  27622. * Creates a webGL program
  27623. * @param vertexCode defines the vertex shader code to use
  27624. * @param fragmentCode defines the fragment shader code to use
  27625. * @param defines defines the string containing the defines to use to compile the shaders
  27626. * @param context defines the webGL context to use (if not set, the current one will be used)
  27627. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27628. * @returns the new webGL program
  27629. */
  27630. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27631. private _createShaderProgram;
  27632. private _finalizeProgram;
  27633. /** @hidden */ isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  27634. /** @hidden */ executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  27635. /**
  27636. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  27637. * @param shaderProgram defines the webGL program to use
  27638. * @param uniformsNames defines the list of uniform names
  27639. * @returns an array of webGL uniform locations
  27640. */
  27641. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  27642. /**
  27643. * Gets the lsit of active attributes for a given webGL program
  27644. * @param shaderProgram defines the webGL program to use
  27645. * @param attributesNames defines the list of attribute names to get
  27646. * @returns an array of indices indicating the offset of each attribute
  27647. */
  27648. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  27649. /**
  27650. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  27651. * @param effect defines the effect to activate
  27652. */
  27653. enableEffect(effect: Nullable<Effect>): void;
  27654. /**
  27655. * Set the value of an uniform to an array of int32
  27656. * @param uniform defines the webGL uniform location where to store the value
  27657. * @param array defines the array of int32 to store
  27658. */
  27659. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27660. /**
  27661. * Set the value of an uniform to an array of int32 (stored as vec2)
  27662. * @param uniform defines the webGL uniform location where to store the value
  27663. * @param array defines the array of int32 to store
  27664. */
  27665. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27666. /**
  27667. * Set the value of an uniform to an array of int32 (stored as vec3)
  27668. * @param uniform defines the webGL uniform location where to store the value
  27669. * @param array defines the array of int32 to store
  27670. */
  27671. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27672. /**
  27673. * Set the value of an uniform to an array of int32 (stored as vec4)
  27674. * @param uniform defines the webGL uniform location where to store the value
  27675. * @param array defines the array of int32 to store
  27676. */
  27677. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27678. /**
  27679. * Set the value of an uniform to an array of float32
  27680. * @param uniform defines the webGL uniform location where to store the value
  27681. * @param array defines the array of float32 to store
  27682. */
  27683. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27684. /**
  27685. * Set the value of an uniform to an array of float32 (stored as vec2)
  27686. * @param uniform defines the webGL uniform location where to store the value
  27687. * @param array defines the array of float32 to store
  27688. */
  27689. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27690. /**
  27691. * Set the value of an uniform to an array of float32 (stored as vec3)
  27692. * @param uniform defines the webGL uniform location where to store the value
  27693. * @param array defines the array of float32 to store
  27694. */
  27695. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27696. /**
  27697. * Set the value of an uniform to an array of float32 (stored as vec4)
  27698. * @param uniform defines the webGL uniform location where to store the value
  27699. * @param array defines the array of float32 to store
  27700. */
  27701. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27702. /**
  27703. * Set the value of an uniform to an array of number
  27704. * @param uniform defines the webGL uniform location where to store the value
  27705. * @param array defines the array of number to store
  27706. */
  27707. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27708. /**
  27709. * Set the value of an uniform to an array of number (stored as vec2)
  27710. * @param uniform defines the webGL uniform location where to store the value
  27711. * @param array defines the array of number to store
  27712. */
  27713. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27714. /**
  27715. * Set the value of an uniform to an array of number (stored as vec3)
  27716. * @param uniform defines the webGL uniform location where to store the value
  27717. * @param array defines the array of number to store
  27718. */
  27719. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27720. /**
  27721. * Set the value of an uniform to an array of number (stored as vec4)
  27722. * @param uniform defines the webGL uniform location where to store the value
  27723. * @param array defines the array of number to store
  27724. */
  27725. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27726. /**
  27727. * Set the value of an uniform to an array of float32 (stored as matrices)
  27728. * @param uniform defines the webGL uniform location where to store the value
  27729. * @param matrices defines the array of float32 to store
  27730. */
  27731. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  27732. /**
  27733. * Set the value of an uniform to a matrix
  27734. * @param uniform defines the webGL uniform location where to store the value
  27735. * @param matrix defines the matrix to store
  27736. */
  27737. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  27738. /**
  27739. * Set the value of an uniform to a matrix (3x3)
  27740. * @param uniform defines the webGL uniform location where to store the value
  27741. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  27742. */
  27743. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27744. /**
  27745. * Set the value of an uniform to a matrix (2x2)
  27746. * @param uniform defines the webGL uniform location where to store the value
  27747. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  27748. */
  27749. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27750. /**
  27751. * Set the value of an uniform to a number (int)
  27752. * @param uniform defines the webGL uniform location where to store the value
  27753. * @param value defines the int number to store
  27754. */
  27755. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27756. /**
  27757. * Set the value of an uniform to a number (float)
  27758. * @param uniform defines the webGL uniform location where to store the value
  27759. * @param value defines the float number to store
  27760. */
  27761. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27762. /**
  27763. * Set the value of an uniform to a vec2
  27764. * @param uniform defines the webGL uniform location where to store the value
  27765. * @param x defines the 1st component of the value
  27766. * @param y defines the 2nd component of the value
  27767. */
  27768. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  27769. /**
  27770. * Set the value of an uniform to a vec3
  27771. * @param uniform defines the webGL uniform location where to store the value
  27772. * @param x defines the 1st component of the value
  27773. * @param y defines the 2nd component of the value
  27774. * @param z defines the 3rd component of the value
  27775. */
  27776. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  27777. /**
  27778. * Set the value of an uniform to a boolean
  27779. * @param uniform defines the webGL uniform location where to store the value
  27780. * @param bool defines the boolean to store
  27781. */
  27782. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  27783. /**
  27784. * Set the value of an uniform to a vec4
  27785. * @param uniform defines the webGL uniform location where to store the value
  27786. * @param x defines the 1st component of the value
  27787. * @param y defines the 2nd component of the value
  27788. * @param z defines the 3rd component of the value
  27789. * @param w defines the 4th component of the value
  27790. */
  27791. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  27792. /**
  27793. * Set the value of an uniform to a Color3
  27794. * @param uniform defines the webGL uniform location where to store the value
  27795. * @param color3 defines the color to store
  27796. */
  27797. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  27798. /**
  27799. * Set the value of an uniform to a Color3 and an alpha value
  27800. * @param uniform defines the webGL uniform location where to store the value
  27801. * @param color3 defines the color to store
  27802. * @param alpha defines the alpha component to store
  27803. */
  27804. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  27805. /**
  27806. * Sets a Color4 on a uniform variable
  27807. * @param uniform defines the uniform location
  27808. * @param color4 defines the value to be set
  27809. */
  27810. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  27811. /**
  27812. * Set various states to the webGL context
  27813. * @param culling defines backface culling state
  27814. * @param zOffset defines the value to apply to zOffset (0 by default)
  27815. * @param force defines if states must be applied even if cache is up to date
  27816. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  27817. */
  27818. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  27819. /**
  27820. * Set the z offset to apply to current rendering
  27821. * @param value defines the offset to apply
  27822. */
  27823. setZOffset(value: number): void;
  27824. /**
  27825. * Gets the current value of the zOffset
  27826. * @returns the current zOffset state
  27827. */
  27828. getZOffset(): number;
  27829. /**
  27830. * Enable or disable depth buffering
  27831. * @param enable defines the state to set
  27832. */
  27833. setDepthBuffer(enable: boolean): void;
  27834. /**
  27835. * Gets a boolean indicating if depth writing is enabled
  27836. * @returns the current depth writing state
  27837. */
  27838. getDepthWrite(): boolean;
  27839. /**
  27840. * Enable or disable depth writing
  27841. * @param enable defines the state to set
  27842. */
  27843. setDepthWrite(enable: boolean): void;
  27844. /**
  27845. * Enable or disable color writing
  27846. * @param enable defines the state to set
  27847. */
  27848. setColorWrite(enable: boolean): void;
  27849. /**
  27850. * Gets a boolean indicating if color writing is enabled
  27851. * @returns the current color writing state
  27852. */
  27853. getColorWrite(): boolean;
  27854. /**
  27855. * Sets alpha constants used by some alpha blending modes
  27856. * @param r defines the red component
  27857. * @param g defines the green component
  27858. * @param b defines the blue component
  27859. * @param a defines the alpha component
  27860. */
  27861. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  27862. /**
  27863. * Sets the current alpha mode
  27864. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  27865. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  27866. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27867. */
  27868. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  27869. /**
  27870. * Gets the current alpha mode
  27871. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27872. * @returns the current alpha mode
  27873. */
  27874. getAlphaMode(): number;
  27875. /**
  27876. * Clears the list of texture accessible through engine.
  27877. * This can help preventing texture load conflict due to name collision.
  27878. */
  27879. clearInternalTexturesCache(): void;
  27880. /**
  27881. * Force the entire cache to be cleared
  27882. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  27883. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  27884. */
  27885. wipeCaches(bruteForce?: boolean): void;
  27886. /**
  27887. * Set the compressed texture format to use, based on the formats you have, and the formats
  27888. * supported by the hardware / browser.
  27889. *
  27890. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  27891. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  27892. * to API arguments needed to compressed textures. This puts the burden on the container
  27893. * generator to house the arcane code for determining these for current & future formats.
  27894. *
  27895. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  27896. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  27897. *
  27898. * Note: The result of this call is not taken into account when a texture is base64.
  27899. *
  27900. * @param formatsAvailable defines the list of those format families you have created
  27901. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  27902. *
  27903. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  27904. * @returns The extension selected.
  27905. */
  27906. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  27907. private _getSamplingParameters;
  27908. private _partialLoadImg;
  27909. private _cascadeLoadImgs;
  27910. /** @hidden */ createTexture(): WebGLTexture;
  27911. /**
  27912. * Usually called from Texture.ts.
  27913. * Passed information to create a WebGLTexture
  27914. * @param urlArg defines a value which contains one of the following:
  27915. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  27916. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  27917. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  27918. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  27919. * @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)
  27920. * @param scene needed for loading to the correct scene
  27921. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  27922. * @param onLoad optional callback to be called upon successful completion
  27923. * @param onError optional callback to be called upon failure
  27924. * @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
  27925. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  27926. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  27927. * @param forcedExtension defines the extension to use to pick the right loader
  27928. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  27929. * @returns a InternalTexture for assignment back into BABYLON.Texture
  27930. */
  27931. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  27932. private _rescaleTexture;
  27933. /**
  27934. * Update a raw texture
  27935. * @param texture defines the texture to update
  27936. * @param data defines the data to store in the texture
  27937. * @param format defines the format of the data
  27938. * @param invertY defines if data must be stored with Y axis inverted
  27939. * @param compression defines the compression used (null by default)
  27940. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27941. */
  27942. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  27943. /**
  27944. * Creates a raw texture
  27945. * @param data defines the data to store in the texture
  27946. * @param width defines the width of the texture
  27947. * @param height defines the height of the texture
  27948. * @param format defines the format of the data
  27949. * @param generateMipMaps defines if the engine should generate the mip levels
  27950. * @param invertY defines if data must be stored with Y axis inverted
  27951. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27952. * @param compression defines the compression used (null by default)
  27953. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27954. * @returns the raw texture inside an InternalTexture
  27955. */
  27956. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  27957. private _unpackFlipYCached;
  27958. /**
  27959. * In case you are sharing the context with other applications, it might
  27960. * be interested to not cache the unpack flip y state to ensure a consistent
  27961. * value would be set.
  27962. */
  27963. enableUnpackFlipYCached: boolean;
  27964. /** @hidden */ unpackFlipY(value: boolean): void;
  27965. /** @hidden */ getUnpackAlignement(): number;
  27966. /**
  27967. * Creates a dynamic texture
  27968. * @param width defines the width of the texture
  27969. * @param height defines the height of the texture
  27970. * @param generateMipMaps defines if the engine should generate the mip levels
  27971. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27972. * @returns the dynamic texture inside an InternalTexture
  27973. */
  27974. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  27975. /**
  27976. * Update the sampling mode of a given texture
  27977. * @param samplingMode defines the required sampling mode
  27978. * @param texture defines the texture to update
  27979. */
  27980. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  27981. /**
  27982. * Update the content of a dynamic texture
  27983. * @param texture defines the texture to update
  27984. * @param canvas defines the canvas containing the source
  27985. * @param invertY defines if data must be stored with Y axis inverted
  27986. * @param premulAlpha defines if alpha is stored as premultiplied
  27987. * @param format defines the format of the data
  27988. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  27989. */
  27990. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  27991. /**
  27992. * Update a video texture
  27993. * @param texture defines the texture to update
  27994. * @param video defines the video element to use
  27995. * @param invertY defines if data must be stored with Y axis inverted
  27996. */
  27997. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  27998. /**
  27999. * Updates a depth texture Comparison Mode and Function.
  28000. * If the comparison Function is equal to 0, the mode will be set to none.
  28001. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28002. * @param texture The texture to set the comparison function for
  28003. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28004. */
  28005. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28006. private _setupDepthStencilTexture;
  28007. /**
  28008. * Creates a depth stencil texture.
  28009. * This is only available in WebGL 2 or with the depth texture extension available.
  28010. * @param size The size of face edge in the texture.
  28011. * @param options The options defining the texture.
  28012. * @returns The texture
  28013. */
  28014. createDepthStencilTexture(size: number | {
  28015. width: number;
  28016. height: number;
  28017. }, options: DepthTextureCreationOptions): InternalTexture;
  28018. /**
  28019. * Creates a depth stencil texture.
  28020. * This is only available in WebGL 2 or with the depth texture extension available.
  28021. * @param size The size of face edge in the texture.
  28022. * @param options The options defining the texture.
  28023. * @returns The texture
  28024. */
  28025. private _createDepthStencilTexture;
  28026. /**
  28027. * Creates a depth stencil cube texture.
  28028. * This is only available in WebGL 2.
  28029. * @param size The size of face edge in the cube texture.
  28030. * @param options The options defining the cube texture.
  28031. * @returns The cube texture
  28032. */
  28033. private _createDepthStencilCubeTexture;
  28034. /**
  28035. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28036. * @param renderTarget The render target to set the frame buffer for
  28037. */
  28038. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28039. /**
  28040. * Creates a new render target texture
  28041. * @param size defines the size of the texture
  28042. * @param options defines the options used to create the texture
  28043. * @returns a new render target texture stored in an InternalTexture
  28044. */
  28045. createRenderTargetTexture(size: number | {
  28046. width: number;
  28047. height: number;
  28048. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28049. /**
  28050. * Create a multi render target texture
  28051. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28052. * @param size defines the size of the texture
  28053. * @param options defines the creation options
  28054. * @returns the cube texture as an InternalTexture
  28055. */
  28056. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28057. private _setupFramebufferDepthAttachments;
  28058. /**
  28059. * Updates the sample count of a render target texture
  28060. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28061. * @param texture defines the texture to update
  28062. * @param samples defines the sample count to set
  28063. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28064. */
  28065. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28066. /**
  28067. * Update the sample count for a given multiple render target texture
  28068. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28069. * @param textures defines the textures to update
  28070. * @param samples defines the sample count to set
  28071. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28072. */
  28073. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28074. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28075. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28076. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28077. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28078. /**
  28079. * Creates a new render target cube texture
  28080. * @param size defines the size of the texture
  28081. * @param options defines the options used to create the texture
  28082. * @returns a new render target cube texture stored in an InternalTexture
  28083. */
  28084. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28085. /**
  28086. * Creates a cube texture
  28087. * @param rootUrl defines the url where the files to load is located
  28088. * @param scene defines the current scene
  28089. * @param files defines the list of files to load (1 per face)
  28090. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28091. * @param onLoad defines an optional callback raised when the texture is loaded
  28092. * @param onError defines an optional callback raised if there is an issue to load the texture
  28093. * @param format defines the format of the data
  28094. * @param forcedExtension defines the extension to use to pick the right loader
  28095. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28096. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28097. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28098. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28099. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28100. * @returns the cube texture as an InternalTexture
  28101. */
  28102. 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>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28103. /**
  28104. * @hidden
  28105. */ setCubeMapTextureParams(loadMipmap: boolean): void;
  28106. /**
  28107. * Update a raw cube texture
  28108. * @param texture defines the texture to udpdate
  28109. * @param data defines the data to store
  28110. * @param format defines the data format
  28111. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28112. * @param invertY defines if data must be stored with Y axis inverted
  28113. * @param compression defines the compression used (null by default)
  28114. * @param level defines which level of the texture to update
  28115. */
  28116. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28117. /**
  28118. * Creates a new raw cube texture
  28119. * @param data defines the array of data to use to create each face
  28120. * @param size defines the size of the textures
  28121. * @param format defines the format of the data
  28122. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28123. * @param generateMipMaps defines if the engine should generate the mip levels
  28124. * @param invertY defines if data must be stored with Y axis inverted
  28125. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28126. * @param compression defines the compression used (null by default)
  28127. * @returns the cube texture as an InternalTexture
  28128. */
  28129. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28130. /**
  28131. * Creates a new raw cube texture from a specified url
  28132. * @param url defines the url where the data is located
  28133. * @param scene defines the current scene
  28134. * @param size defines the size of the textures
  28135. * @param format defines the format of the data
  28136. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28137. * @param noMipmap defines if the engine should avoid generating the mip levels
  28138. * @param callback defines a callback used to extract texture data from loaded data
  28139. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28140. * @param onLoad defines a callback called when texture is loaded
  28141. * @param onError defines a callback called if there is an error
  28142. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28143. * @param invertY defines if data must be stored with Y axis inverted
  28144. * @returns the cube texture as an InternalTexture
  28145. */
  28146. 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;
  28147. /**
  28148. * Update a raw 3D texture
  28149. * @param texture defines the texture to update
  28150. * @param data defines the data to store
  28151. * @param format defines the data format
  28152. * @param invertY defines if data must be stored with Y axis inverted
  28153. * @param compression defines the used compression (can be null)
  28154. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28155. */
  28156. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28157. /**
  28158. * Creates a new raw 3D texture
  28159. * @param data defines the data used to create the texture
  28160. * @param width defines the width of the texture
  28161. * @param height defines the height of the texture
  28162. * @param depth defines the depth of the texture
  28163. * @param format defines the format of the texture
  28164. * @param generateMipMaps defines if the engine must generate mip levels
  28165. * @param invertY defines if data must be stored with Y axis inverted
  28166. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28167. * @param compression defines the compressed used (can be null)
  28168. * @param textureType defines the compressed used (can be null)
  28169. * @returns a new raw 3D texture (stored in an InternalTexture)
  28170. */
  28171. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28172. private _prepareWebGLTextureContinuation;
  28173. private _prepareWebGLTexture;
  28174. private _convertRGBtoRGBATextureData;
  28175. /** @hidden */ releaseFramebufferObjects(texture: InternalTexture): void;
  28176. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  28177. private setProgram;
  28178. private _boundUniforms;
  28179. /**
  28180. * Binds an effect to the webGL context
  28181. * @param effect defines the effect to bind
  28182. */
  28183. bindSamplers(effect: Effect): void;
  28184. private _moveBoundTextureOnTop;
  28185. private _getCorrectTextureChannel;
  28186. private _linkTrackers;
  28187. private _removeDesignatedSlot;
  28188. private _activateCurrentTexture;
  28189. /** @hidden */ bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28190. /** @hidden */ bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28191. /**
  28192. * Sets a texture to the webGL context from a postprocess
  28193. * @param channel defines the channel to use
  28194. * @param postProcess defines the source postprocess
  28195. */
  28196. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28197. /**
  28198. * Binds the output of the passed in post process to the texture channel specified
  28199. * @param channel The channel the texture should be bound to
  28200. * @param postProcess The post process which's output should be bound
  28201. */
  28202. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28203. /**
  28204. * Unbind all textures from the webGL context
  28205. */
  28206. unbindAllTextures(): void;
  28207. /**
  28208. * Sets a texture to the according uniform.
  28209. * @param channel The texture channel
  28210. * @param uniform The uniform to set
  28211. * @param texture The texture to apply
  28212. */
  28213. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28214. /**
  28215. * Sets a depth stencil texture from a render target to the according uniform.
  28216. * @param channel The texture channel
  28217. * @param uniform The uniform to set
  28218. * @param texture The render target texture containing the depth stencil texture to apply
  28219. */
  28220. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28221. private _bindSamplerUniformToChannel;
  28222. private _getTextureWrapMode;
  28223. private _setTexture;
  28224. /**
  28225. * Sets an array of texture to the webGL context
  28226. * @param channel defines the channel where the texture array must be set
  28227. * @param uniform defines the associated uniform location
  28228. * @param textures defines the array of textures to bind
  28229. */
  28230. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28231. /** @hidden */ setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28232. private _setTextureParameterFloat;
  28233. private _setTextureParameterInteger;
  28234. /**
  28235. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28236. * @param x defines the x coordinate of the rectangle where pixels must be read
  28237. * @param y defines the y coordinate of the rectangle where pixels must be read
  28238. * @param width defines the width of the rectangle where pixels must be read
  28239. * @param height defines the height of the rectangle where pixels must be read
  28240. * @returns a Uint8Array containing RGBA colors
  28241. */
  28242. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28243. /**
  28244. * Add an externaly attached data from its key.
  28245. * This method call will fail and return false, if such key already exists.
  28246. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28247. * @param key the unique key that identifies the data
  28248. * @param data the data object to associate to the key for this Engine instance
  28249. * @return true if no such key were already present and the data was added successfully, false otherwise
  28250. */
  28251. addExternalData<T>(key: string, data: T): boolean;
  28252. /**
  28253. * Get an externaly attached data from its key
  28254. * @param key the unique key that identifies the data
  28255. * @return the associated data, if present (can be null), or undefined if not present
  28256. */
  28257. getExternalData<T>(key: string): T;
  28258. /**
  28259. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28260. * @param key the unique key that identifies the data
  28261. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28262. * @return the associated data, can be null if the factory returned null.
  28263. */
  28264. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28265. /**
  28266. * Remove an externaly attached data from the Engine instance
  28267. * @param key the unique key that identifies the data
  28268. * @return true if the data was successfully removed, false if it doesn't exist
  28269. */
  28270. removeExternalData(key: string): boolean;
  28271. /**
  28272. * Unbind all vertex attributes from the webGL context
  28273. */
  28274. unbindAllAttributes(): void;
  28275. /**
  28276. * 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
  28277. */
  28278. releaseEffects(): void;
  28279. /**
  28280. * Dispose and release all associated resources
  28281. */
  28282. dispose(): void;
  28283. /**
  28284. * Display the loading screen
  28285. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28286. */
  28287. displayLoadingUI(): void;
  28288. /**
  28289. * Hide the loading screen
  28290. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28291. */
  28292. hideLoadingUI(): void;
  28293. /**
  28294. * Gets the current loading screen object
  28295. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28296. */
  28297. /**
  28298. * Sets the current loading screen object
  28299. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28300. */
  28301. loadingScreen: ILoadingScreen;
  28302. /**
  28303. * Sets the current loading screen text
  28304. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28305. */
  28306. loadingUIText: string;
  28307. /**
  28308. * Sets the current loading screen background color
  28309. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28310. */
  28311. loadingUIBackgroundColor: string;
  28312. /**
  28313. * Attach a new callback raised when context lost event is fired
  28314. * @param callback defines the callback to call
  28315. */
  28316. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28317. /**
  28318. * Attach a new callback raised when context restored event is fired
  28319. * @param callback defines the callback to call
  28320. */
  28321. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28322. /**
  28323. * Gets the source code of the vertex shader associated with a specific webGL program
  28324. * @param program defines the program to use
  28325. * @returns a string containing the source code of the vertex shader associated with the program
  28326. */
  28327. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28328. /**
  28329. * Gets the source code of the fragment shader associated with a specific webGL program
  28330. * @param program defines the program to use
  28331. * @returns a string containing the source code of the fragment shader associated with the program
  28332. */
  28333. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28334. /**
  28335. * Get the current error code of the webGL context
  28336. * @returns the error code
  28337. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28338. */
  28339. getError(): number;
  28340. /**
  28341. * Gets the current framerate
  28342. * @returns a number representing the framerate
  28343. */
  28344. getFps(): number;
  28345. /**
  28346. * Gets the time spent between current and previous frame
  28347. * @returns a number representing the delta time in ms
  28348. */
  28349. getDeltaTime(): number;
  28350. private _measureFps;
  28351. /** @hidden */ readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28352. private _canRenderToFloatFramebuffer;
  28353. private _canRenderToHalfFloatFramebuffer;
  28354. private _canRenderToFramebuffer;
  28355. /** @hidden */ getWebGLTextureType(type: number): number;
  28356. private _getInternalFormat;
  28357. /** @hidden */ getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28358. /** @hidden */ getRGBAMultiSampleBufferFormat(type: number): number;
  28359. /** @hidden */ 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;
  28360. /** @hidden */ loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28361. private _partialLoadFile;
  28362. private _cascadeLoadFiles;
  28363. /**
  28364. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28365. * @returns true if the engine can be created
  28366. * @ignorenaming
  28367. */
  28368. static isSupported(): boolean;
  28369. }
  28370. }
  28371. declare module BABYLON {
  28372. /**
  28373. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28374. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28375. */
  28376. export class EffectFallbacks {
  28377. private _defines;
  28378. private _currentRank;
  28379. private _maxRank;
  28380. private _mesh;
  28381. /**
  28382. * Removes the fallback from the bound mesh.
  28383. */
  28384. unBindMesh(): void;
  28385. /**
  28386. * Adds a fallback on the specified property.
  28387. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28388. * @param define The name of the define in the shader
  28389. */
  28390. addFallback(rank: number, define: string): void;
  28391. /**
  28392. * Sets the mesh to use CPU skinning when needing to fallback.
  28393. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28394. * @param mesh The mesh to use the fallbacks.
  28395. */
  28396. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28397. /**
  28398. * Checks to see if more fallbacks are still availible.
  28399. */
  28400. readonly isMoreFallbacks: boolean;
  28401. /**
  28402. * Removes the defines that shoould be removed when falling back.
  28403. * @param currentDefines defines the current define statements for the shader.
  28404. * @param effect defines the current effect we try to compile
  28405. * @returns The resulting defines with defines of the current rank removed.
  28406. */
  28407. reduce(currentDefines: string, effect: Effect): string;
  28408. }
  28409. /**
  28410. * Options to be used when creating an effect.
  28411. */
  28412. export class EffectCreationOptions {
  28413. /**
  28414. * Atrributes that will be used in the shader.
  28415. */
  28416. attributes: string[];
  28417. /**
  28418. * Uniform varible names that will be set in the shader.
  28419. */
  28420. uniformsNames: string[];
  28421. /**
  28422. * Uniform buffer varible names that will be set in the shader.
  28423. */
  28424. uniformBuffersNames: string[];
  28425. /**
  28426. * Sampler texture variable names that will be set in the shader.
  28427. */
  28428. samplers: string[];
  28429. /**
  28430. * Define statements that will be set in the shader.
  28431. */
  28432. defines: any;
  28433. /**
  28434. * Possible fallbacks for this effect to improve performance when needed.
  28435. */
  28436. fallbacks: Nullable<EffectFallbacks>;
  28437. /**
  28438. * Callback that will be called when the shader is compiled.
  28439. */
  28440. onCompiled: Nullable<(effect: Effect) => void>;
  28441. /**
  28442. * Callback that will be called if an error occurs during shader compilation.
  28443. */
  28444. onError: Nullable<(effect: Effect, errors: string) => void>;
  28445. /**
  28446. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28447. */
  28448. indexParameters: any;
  28449. /**
  28450. * Max number of lights that can be used in the shader.
  28451. */
  28452. maxSimultaneousLights: number;
  28453. /**
  28454. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28455. */
  28456. transformFeedbackVaryings: Nullable<string[]>;
  28457. }
  28458. /**
  28459. * Effect containing vertex and fragment shader that can be executed on an object.
  28460. */
  28461. export class Effect {
  28462. /**
  28463. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28464. */
  28465. static ShadersRepository: string;
  28466. /**
  28467. * Name of the effect.
  28468. */
  28469. name: any;
  28470. /**
  28471. * String container all the define statements that should be set on the shader.
  28472. */
  28473. defines: string;
  28474. /**
  28475. * Callback that will be called when the shader is compiled.
  28476. */
  28477. onCompiled: Nullable<(effect: Effect) => void>;
  28478. /**
  28479. * Callback that will be called if an error occurs during shader compilation.
  28480. */
  28481. onError: Nullable<(effect: Effect, errors: string) => void>;
  28482. /**
  28483. * Callback that will be called when effect is bound.
  28484. */
  28485. onBind: Nullable<(effect: Effect) => void>;
  28486. /**
  28487. * Unique ID of the effect.
  28488. */
  28489. uniqueId: number;
  28490. /**
  28491. * Observable that will be called when the shader is compiled.
  28492. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28493. */
  28494. onCompileObservable: Observable<Effect>;
  28495. /**
  28496. * Observable that will be called if an error occurs during shader compilation.
  28497. */
  28498. onErrorObservable: Observable<Effect>;
  28499. /** @hidden */ onBindObservable: Nullable<Observable<Effect>>;
  28500. /**
  28501. * Observable that will be called when effect is bound.
  28502. */
  28503. readonly onBindObservable: Observable<Effect>;
  28504. /** @hidden */ bonesComputationForcedToCPU: boolean;
  28505. private static _uniqueIdSeed;
  28506. private _engine;
  28507. private _uniformBuffersNames;
  28508. private _uniformsNames;
  28509. private _samplers;
  28510. private _isReady;
  28511. private _compilationError;
  28512. private _attributesNames;
  28513. private _attributes;
  28514. private _uniforms;
  28515. /**
  28516. * Key for the effect.
  28517. * @hidden
  28518. */ key: string;
  28519. private _indexParameters;
  28520. private _fallbacks;
  28521. private _vertexSourceCode;
  28522. private _fragmentSourceCode;
  28523. private _vertexSourceCodeOverride;
  28524. private _fragmentSourceCodeOverride;
  28525. private _transformFeedbackVaryings;
  28526. /**
  28527. * Compiled shader to webGL program.
  28528. * @hidden
  28529. */ program: WebGLProgram;
  28530. private _valueCache;
  28531. private static _baseCache;
  28532. /**
  28533. * Instantiates an effect.
  28534. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28535. * @param baseName Name of the effect.
  28536. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28537. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28538. * @param samplers List of sampler variables that will be passed to the shader.
  28539. * @param engine Engine to be used to render the effect
  28540. * @param defines Define statements to be added to the shader.
  28541. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28542. * @param onCompiled Callback that will be called when the shader is compiled.
  28543. * @param onError Callback that will be called if an error occurs during shader compilation.
  28544. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28545. */
  28546. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28547. /**
  28548. * Unique key for this effect
  28549. */
  28550. readonly key: string;
  28551. /**
  28552. * If the effect has been compiled and prepared.
  28553. * @returns if the effect is compiled and prepared.
  28554. */
  28555. isReady(): boolean;
  28556. /**
  28557. * The engine the effect was initialized with.
  28558. * @returns the engine.
  28559. */
  28560. getEngine(): Engine;
  28561. /**
  28562. * The compiled webGL program for the effect
  28563. * @returns the webGL program.
  28564. */
  28565. getProgram(): WebGLProgram;
  28566. /**
  28567. * The set of names of attribute variables for the shader.
  28568. * @returns An array of attribute names.
  28569. */
  28570. getAttributesNames(): string[];
  28571. /**
  28572. * Returns the attribute at the given index.
  28573. * @param index The index of the attribute.
  28574. * @returns The location of the attribute.
  28575. */
  28576. getAttributeLocation(index: number): number;
  28577. /**
  28578. * Returns the attribute based on the name of the variable.
  28579. * @param name of the attribute to look up.
  28580. * @returns the attribute location.
  28581. */
  28582. getAttributeLocationByName(name: string): number;
  28583. /**
  28584. * The number of attributes.
  28585. * @returns the numnber of attributes.
  28586. */
  28587. getAttributesCount(): number;
  28588. /**
  28589. * Gets the index of a uniform variable.
  28590. * @param uniformName of the uniform to look up.
  28591. * @returns the index.
  28592. */
  28593. getUniformIndex(uniformName: string): number;
  28594. /**
  28595. * Returns the attribute based on the name of the variable.
  28596. * @param uniformName of the uniform to look up.
  28597. * @returns the location of the uniform.
  28598. */
  28599. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28600. /**
  28601. * Returns an array of sampler variable names
  28602. * @returns The array of sampler variable neames.
  28603. */
  28604. getSamplers(): string[];
  28605. /**
  28606. * The error from the last compilation.
  28607. * @returns the error string.
  28608. */
  28609. getCompilationError(): string;
  28610. /**
  28611. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28612. * @param func The callback to be used.
  28613. */
  28614. executeWhenCompiled(func: (effect: Effect) => void): void;
  28615. private _checkIsReady;
  28616. /** @hidden */ loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28617. /** @hidden */ loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28618. /** @hidden */ dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28619. private _processShaderConversion;
  28620. private _processIncludes;
  28621. private _processPrecision;
  28622. /**
  28623. * Recompiles the webGL program
  28624. * @param vertexSourceCode The source code for the vertex shader.
  28625. * @param fragmentSourceCode The source code for the fragment shader.
  28626. * @param onCompiled Callback called when completed.
  28627. * @param onError Callback called on error.
  28628. * @hidden
  28629. */ rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  28630. /**
  28631. * Gets the uniform locations of the the specified variable names
  28632. * @param names THe names of the variables to lookup.
  28633. * @returns Array of locations in the same order as variable names.
  28634. */
  28635. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  28636. /**
  28637. * Prepares the effect
  28638. * @hidden
  28639. */ prepareEffect(): void;
  28640. /**
  28641. * Checks if the effect is supported. (Must be called after compilation)
  28642. */
  28643. readonly isSupported: boolean;
  28644. /**
  28645. * Binds a texture to the engine to be used as output of the shader.
  28646. * @param channel Name of the output variable.
  28647. * @param texture Texture to bind.
  28648. * @hidden
  28649. */ bindTexture(channel: string, texture: InternalTexture): void;
  28650. /**
  28651. * Sets a texture on the engine to be used in the shader.
  28652. * @param channel Name of the sampler variable.
  28653. * @param texture Texture to set.
  28654. */
  28655. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28656. /**
  28657. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28658. * @param channel Name of the sampler variable.
  28659. * @param texture Texture to set.
  28660. */
  28661. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28662. /**
  28663. * Sets an array of textures on the engine to be used in the shader.
  28664. * @param channel Name of the variable.
  28665. * @param textures Textures to set.
  28666. */
  28667. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28668. /**
  28669. * 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)
  28670. * @param channel Name of the sampler variable.
  28671. * @param postProcess Post process to get the input texture from.
  28672. */
  28673. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28674. /**
  28675. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28676. * 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)
  28677. * @param channel Name of the sampler variable.
  28678. * @param postProcess Post process to get the output texture from.
  28679. */
  28680. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28681. /** @hidden */ cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  28682. /** @hidden */ cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28683. /** @hidden */ cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28684. /** @hidden */ cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28685. /**
  28686. * Binds a buffer to a uniform.
  28687. * @param buffer Buffer to bind.
  28688. * @param name Name of the uniform variable to bind to.
  28689. */
  28690. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  28691. /**
  28692. * Binds block to a uniform.
  28693. * @param blockName Name of the block to bind.
  28694. * @param index Index to bind.
  28695. */
  28696. bindUniformBlock(blockName: string, index: number): void;
  28697. /**
  28698. * Sets an interger value on a uniform variable.
  28699. * @param uniformName Name of the variable.
  28700. * @param value Value to be set.
  28701. * @returns this effect.
  28702. */
  28703. setInt(uniformName: string, value: number): Effect;
  28704. /**
  28705. * Sets an int array on a uniform variable.
  28706. * @param uniformName Name of the variable.
  28707. * @param array array to be set.
  28708. * @returns this effect.
  28709. */
  28710. setIntArray(uniformName: string, array: Int32Array): Effect;
  28711. /**
  28712. * 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)
  28713. * @param uniformName Name of the variable.
  28714. * @param array array to be set.
  28715. * @returns this effect.
  28716. */
  28717. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28718. /**
  28719. * 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)
  28720. * @param uniformName Name of the variable.
  28721. * @param array array to be set.
  28722. * @returns this effect.
  28723. */
  28724. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28725. /**
  28726. * 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)
  28727. * @param uniformName Name of the variable.
  28728. * @param array array to be set.
  28729. * @returns this effect.
  28730. */
  28731. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28732. /**
  28733. * Sets an float array on a uniform variable.
  28734. * @param uniformName Name of the variable.
  28735. * @param array array to be set.
  28736. * @returns this effect.
  28737. */
  28738. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28739. /**
  28740. * 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)
  28741. * @param uniformName Name of the variable.
  28742. * @param array array to be set.
  28743. * @returns this effect.
  28744. */
  28745. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28746. /**
  28747. * 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)
  28748. * @param uniformName Name of the variable.
  28749. * @param array array to be set.
  28750. * @returns this effect.
  28751. */
  28752. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28753. /**
  28754. * 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)
  28755. * @param uniformName Name of the variable.
  28756. * @param array array to be set.
  28757. * @returns this effect.
  28758. */
  28759. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28760. /**
  28761. * Sets an array on a uniform variable.
  28762. * @param uniformName Name of the variable.
  28763. * @param array array to be set.
  28764. * @returns this effect.
  28765. */
  28766. setArray(uniformName: string, array: number[]): Effect;
  28767. /**
  28768. * 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)
  28769. * @param uniformName Name of the variable.
  28770. * @param array array to be set.
  28771. * @returns this effect.
  28772. */
  28773. setArray2(uniformName: string, array: number[]): Effect;
  28774. /**
  28775. * 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)
  28776. * @param uniformName Name of the variable.
  28777. * @param array array to be set.
  28778. * @returns this effect.
  28779. */
  28780. setArray3(uniformName: string, array: number[]): Effect;
  28781. /**
  28782. * 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)
  28783. * @param uniformName Name of the variable.
  28784. * @param array array to be set.
  28785. * @returns this effect.
  28786. */
  28787. setArray4(uniformName: string, array: number[]): Effect;
  28788. /**
  28789. * Sets matrices on a uniform variable.
  28790. * @param uniformName Name of the variable.
  28791. * @param matrices matrices to be set.
  28792. * @returns this effect.
  28793. */
  28794. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28795. /**
  28796. * Sets matrix on a uniform variable.
  28797. * @param uniformName Name of the variable.
  28798. * @param matrix matrix to be set.
  28799. * @returns this effect.
  28800. */
  28801. setMatrix(uniformName: string, matrix: Matrix): Effect;
  28802. /**
  28803. * 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)
  28804. * @param uniformName Name of the variable.
  28805. * @param matrix matrix to be set.
  28806. * @returns this effect.
  28807. */
  28808. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28809. /**
  28810. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28811. * @param uniformName Name of the variable.
  28812. * @param matrix matrix to be set.
  28813. * @returns this effect.
  28814. */
  28815. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28816. /**
  28817. * Sets a float on a uniform variable.
  28818. * @param uniformName Name of the variable.
  28819. * @param value value to be set.
  28820. * @returns this effect.
  28821. */
  28822. setFloat(uniformName: string, value: number): Effect;
  28823. /**
  28824. * Sets a boolean on a uniform variable.
  28825. * @param uniformName Name of the variable.
  28826. * @param bool value to be set.
  28827. * @returns this effect.
  28828. */
  28829. setBool(uniformName: string, bool: boolean): Effect;
  28830. /**
  28831. * Sets a Vector2 on a uniform variable.
  28832. * @param uniformName Name of the variable.
  28833. * @param vector2 vector2 to be set.
  28834. * @returns this effect.
  28835. */
  28836. setVector2(uniformName: string, vector2: Vector2): Effect;
  28837. /**
  28838. * Sets a float2 on a uniform variable.
  28839. * @param uniformName Name of the variable.
  28840. * @param x First float in float2.
  28841. * @param y Second float in float2.
  28842. * @returns this effect.
  28843. */
  28844. setFloat2(uniformName: string, x: number, y: number): Effect;
  28845. /**
  28846. * Sets a Vector3 on a uniform variable.
  28847. * @param uniformName Name of the variable.
  28848. * @param vector3 Value to be set.
  28849. * @returns this effect.
  28850. */
  28851. setVector3(uniformName: string, vector3: Vector3): Effect;
  28852. /**
  28853. * Sets a float3 on a uniform variable.
  28854. * @param uniformName Name of the variable.
  28855. * @param x First float in float3.
  28856. * @param y Second float in float3.
  28857. * @param z Third float in float3.
  28858. * @returns this effect.
  28859. */
  28860. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28861. /**
  28862. * Sets a Vector4 on a uniform variable.
  28863. * @param uniformName Name of the variable.
  28864. * @param vector4 Value to be set.
  28865. * @returns this effect.
  28866. */
  28867. setVector4(uniformName: string, vector4: Vector4): Effect;
  28868. /**
  28869. * Sets a float4 on a uniform variable.
  28870. * @param uniformName Name of the variable.
  28871. * @param x First float in float4.
  28872. * @param y Second float in float4.
  28873. * @param z Third float in float4.
  28874. * @param w Fourth float in float4.
  28875. * @returns this effect.
  28876. */
  28877. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28878. /**
  28879. * Sets a Color3 on a uniform variable.
  28880. * @param uniformName Name of the variable.
  28881. * @param color3 Value to be set.
  28882. * @returns this effect.
  28883. */
  28884. setColor3(uniformName: string, color3: Color3): Effect;
  28885. /**
  28886. * Sets a Color4 on a uniform variable.
  28887. * @param uniformName Name of the variable.
  28888. * @param color3 Value to be set.
  28889. * @param alpha Alpha value to be set.
  28890. * @returns this effect.
  28891. */
  28892. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  28893. /**
  28894. * Sets a Color4 on a uniform variable
  28895. * @param uniformName defines the name of the variable
  28896. * @param color4 defines the value to be set
  28897. * @returns this effect.
  28898. */
  28899. setDirectColor4(uniformName: string, color4: Color4): Effect;
  28900. /**
  28901. * This function will add a new shader to the shader store
  28902. * @param name the name of the shader
  28903. * @param pixelShader optional pixel shader content
  28904. * @param vertexShader optional vertex shader content
  28905. */
  28906. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28907. /**
  28908. * Store of each shader (The can be looked up using effect.key)
  28909. */
  28910. static ShadersStore: {
  28911. [key: string]: string;
  28912. };
  28913. /**
  28914. * Store of each included file for a shader (The can be looked up using effect.key)
  28915. */
  28916. static IncludesShadersStore: {
  28917. [key: string]: string;
  28918. };
  28919. /**
  28920. * Resets the cache of effects.
  28921. */
  28922. static ResetCache(): void;
  28923. }
  28924. }
  28925. declare module BABYLON {
  28926. /**
  28927. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28928. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28929. * 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;
  28930. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28931. */
  28932. export class ColorCurves {
  28933. private _dirty;
  28934. private _tempColor;
  28935. private _globalCurve;
  28936. private _highlightsCurve;
  28937. private _midtonesCurve;
  28938. private _shadowsCurve;
  28939. private _positiveCurve;
  28940. private _negativeCurve;
  28941. private _globalHue;
  28942. private _globalDensity;
  28943. private _globalSaturation;
  28944. private _globalExposure;
  28945. /**
  28946. * Gets the global Hue value.
  28947. * 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).
  28948. */
  28949. /**
  28950. * Sets the global Hue value.
  28951. * 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).
  28952. */
  28953. globalHue: number;
  28954. /**
  28955. * Gets the global Density value.
  28956. * 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.
  28957. * Values less than zero provide a filter of opposite hue.
  28958. */
  28959. /**
  28960. * Sets the global Density value.
  28961. * 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.
  28962. * Values less than zero provide a filter of opposite hue.
  28963. */
  28964. globalDensity: number;
  28965. /**
  28966. * Gets the global Saturation value.
  28967. * 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.
  28968. */
  28969. /**
  28970. * Sets the global Saturation value.
  28971. * 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.
  28972. */
  28973. globalSaturation: number;
  28974. /**
  28975. * Gets the global Exposure value.
  28976. * 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.
  28977. */
  28978. /**
  28979. * Sets the global Exposure value.
  28980. * 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.
  28981. */
  28982. globalExposure: number;
  28983. private _highlightsHue;
  28984. private _highlightsDensity;
  28985. private _highlightsSaturation;
  28986. private _highlightsExposure;
  28987. /**
  28988. * Gets the highlights Hue value.
  28989. * 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).
  28990. */
  28991. /**
  28992. * Sets the highlights Hue value.
  28993. * 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).
  28994. */
  28995. highlightsHue: number;
  28996. /**
  28997. * Gets the highlights Density value.
  28998. * 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.
  28999. * Values less than zero provide a filter of opposite hue.
  29000. */
  29001. /**
  29002. * Sets the highlights Density value.
  29003. * 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.
  29004. * Values less than zero provide a filter of opposite hue.
  29005. */
  29006. highlightsDensity: number;
  29007. /**
  29008. * Gets the highlights Saturation value.
  29009. * 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.
  29010. */
  29011. /**
  29012. * Sets the highlights Saturation value.
  29013. * 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.
  29014. */
  29015. highlightsSaturation: number;
  29016. /**
  29017. * Gets the highlights Exposure value.
  29018. * 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.
  29019. */
  29020. /**
  29021. * Sets the highlights Exposure value.
  29022. * 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.
  29023. */
  29024. highlightsExposure: number;
  29025. private _midtonesHue;
  29026. private _midtonesDensity;
  29027. private _midtonesSaturation;
  29028. private _midtonesExposure;
  29029. /**
  29030. * Gets the midtones Hue value.
  29031. * 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).
  29032. */
  29033. /**
  29034. * Sets the midtones Hue value.
  29035. * 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).
  29036. */
  29037. midtonesHue: number;
  29038. /**
  29039. * Gets the midtones Density value.
  29040. * 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.
  29041. * Values less than zero provide a filter of opposite hue.
  29042. */
  29043. /**
  29044. * Sets the midtones Density value.
  29045. * 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.
  29046. * Values less than zero provide a filter of opposite hue.
  29047. */
  29048. midtonesDensity: number;
  29049. /**
  29050. * Gets the midtones Saturation value.
  29051. * 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.
  29052. */
  29053. /**
  29054. * Sets the midtones Saturation value.
  29055. * 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.
  29056. */
  29057. midtonesSaturation: number;
  29058. /**
  29059. * Gets the midtones Exposure value.
  29060. * 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.
  29061. */
  29062. /**
  29063. * Sets the midtones Exposure value.
  29064. * 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.
  29065. */
  29066. midtonesExposure: number;
  29067. private _shadowsHue;
  29068. private _shadowsDensity;
  29069. private _shadowsSaturation;
  29070. private _shadowsExposure;
  29071. /**
  29072. * Gets the shadows Hue value.
  29073. * 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).
  29074. */
  29075. /**
  29076. * Sets the shadows Hue value.
  29077. * 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).
  29078. */
  29079. shadowsHue: number;
  29080. /**
  29081. * Gets the shadows Density value.
  29082. * 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.
  29083. * Values less than zero provide a filter of opposite hue.
  29084. */
  29085. /**
  29086. * Sets the shadows Density value.
  29087. * 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.
  29088. * Values less than zero provide a filter of opposite hue.
  29089. */
  29090. shadowsDensity: number;
  29091. /**
  29092. * Gets the shadows Saturation value.
  29093. * 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.
  29094. */
  29095. /**
  29096. * Sets the shadows Saturation value.
  29097. * 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.
  29098. */
  29099. shadowsSaturation: number;
  29100. /**
  29101. * Gets the shadows Exposure value.
  29102. * 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.
  29103. */
  29104. /**
  29105. * Sets the shadows Exposure value.
  29106. * 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.
  29107. */
  29108. shadowsExposure: number;
  29109. /**
  29110. * Returns the class name
  29111. * @returns The class name
  29112. */
  29113. getClassName(): string;
  29114. /**
  29115. * Binds the color curves to the shader.
  29116. * @param colorCurves The color curve to bind
  29117. * @param effect The effect to bind to
  29118. * @param positiveUniform The positive uniform shader parameter
  29119. * @param neutralUniform The neutral uniform shader parameter
  29120. * @param negativeUniform The negative uniform shader parameter
  29121. */
  29122. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29123. /**
  29124. * Prepare the list of uniforms associated with the ColorCurves effects.
  29125. * @param uniformsList The list of uniforms used in the effect
  29126. */
  29127. static PrepareUniforms(uniformsList: string[]): void;
  29128. /**
  29129. * Returns color grading data based on a hue, density, saturation and exposure value.
  29130. * @param filterHue The hue of the color filter.
  29131. * @param filterDensity The density of the color filter.
  29132. * @param saturation The saturation.
  29133. * @param exposure The exposure.
  29134. * @param result The result data container.
  29135. */
  29136. private getColorGradingDataToRef;
  29137. /**
  29138. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29139. * @param value The input slider value in range [-100,100].
  29140. * @returns Adjusted value.
  29141. */
  29142. private static applyColorGradingSliderNonlinear;
  29143. /**
  29144. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29145. * @param hue The hue (H) input.
  29146. * @param saturation The saturation (S) input.
  29147. * @param brightness The brightness (B) input.
  29148. * @result An RGBA color represented as Vector4.
  29149. */
  29150. private static fromHSBToRef;
  29151. /**
  29152. * Returns a value clamped between min and max
  29153. * @param value The value to clamp
  29154. * @param min The minimum of value
  29155. * @param max The maximum of value
  29156. * @returns The clamped value.
  29157. */
  29158. private static clamp;
  29159. /**
  29160. * Clones the current color curve instance.
  29161. * @return The cloned curves
  29162. */
  29163. clone(): ColorCurves;
  29164. /**
  29165. * Serializes the current color curve instance to a json representation.
  29166. * @return a JSON representation
  29167. */
  29168. serialize(): any;
  29169. /**
  29170. * Parses the color curve from a json representation.
  29171. * @param source the JSON source to parse
  29172. * @return The parsed curves
  29173. */
  29174. static Parse(source: any): ColorCurves;
  29175. }
  29176. }
  29177. declare module BABYLON {
  29178. /**
  29179. * Interface to follow in your material defines to integrate easily the
  29180. * Image proccessing functions.
  29181. * @hidden
  29182. */
  29183. export interface IImageProcessingConfigurationDefines {
  29184. IMAGEPROCESSING: boolean;
  29185. VIGNETTE: boolean;
  29186. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29187. VIGNETTEBLENDMODEOPAQUE: boolean;
  29188. TONEMAPPING: boolean;
  29189. TONEMAPPING_ACES: boolean;
  29190. CONTRAST: boolean;
  29191. EXPOSURE: boolean;
  29192. COLORCURVES: boolean;
  29193. COLORGRADING: boolean;
  29194. COLORGRADING3D: boolean;
  29195. SAMPLER3DGREENDEPTH: boolean;
  29196. SAMPLER3DBGRMAP: boolean;
  29197. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29198. }
  29199. /**
  29200. * @hidden
  29201. */
  29202. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29203. IMAGEPROCESSING: boolean;
  29204. VIGNETTE: boolean;
  29205. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29206. VIGNETTEBLENDMODEOPAQUE: boolean;
  29207. TONEMAPPING: boolean;
  29208. TONEMAPPING_ACES: boolean;
  29209. CONTRAST: boolean;
  29210. COLORCURVES: boolean;
  29211. COLORGRADING: boolean;
  29212. COLORGRADING3D: boolean;
  29213. SAMPLER3DGREENDEPTH: boolean;
  29214. SAMPLER3DBGRMAP: boolean;
  29215. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29216. EXPOSURE: boolean;
  29217. constructor();
  29218. }
  29219. /**
  29220. * This groups together the common properties used for image processing either in direct forward pass
  29221. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29222. * or not.
  29223. */
  29224. export class ImageProcessingConfiguration {
  29225. /**
  29226. * Default tone mapping applied in BabylonJS.
  29227. */
  29228. static readonly TONEMAPPING_STANDARD: number;
  29229. /**
  29230. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29231. * to other engines rendering to increase portability.
  29232. */
  29233. static readonly TONEMAPPING_ACES: number;
  29234. /**
  29235. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29236. */
  29237. colorCurves: Nullable<ColorCurves>;
  29238. private _colorCurvesEnabled;
  29239. /**
  29240. * Gets wether the color curves effect is enabled.
  29241. */
  29242. /**
  29243. * Sets wether the color curves effect is enabled.
  29244. */
  29245. colorCurvesEnabled: boolean;
  29246. private _colorGradingTexture;
  29247. /**
  29248. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29249. */
  29250. /**
  29251. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29252. */
  29253. colorGradingTexture: Nullable<BaseTexture>;
  29254. private _colorGradingEnabled;
  29255. /**
  29256. * Gets wether the color grading effect is enabled.
  29257. */
  29258. /**
  29259. * Sets wether the color grading effect is enabled.
  29260. */
  29261. colorGradingEnabled: boolean;
  29262. private _colorGradingWithGreenDepth;
  29263. /**
  29264. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29265. */
  29266. /**
  29267. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29268. */
  29269. colorGradingWithGreenDepth: boolean;
  29270. private _colorGradingBGR;
  29271. /**
  29272. * Gets wether the color grading texture contains BGR values.
  29273. */
  29274. /**
  29275. * Sets wether the color grading texture contains BGR values.
  29276. */
  29277. colorGradingBGR: boolean;
  29278. /** @hidden */ exposure: number;
  29279. /**
  29280. * Gets the Exposure used in the effect.
  29281. */
  29282. /**
  29283. * Sets the Exposure used in the effect.
  29284. */
  29285. exposure: number;
  29286. private _toneMappingEnabled;
  29287. /**
  29288. * Gets wether the tone mapping effect is enabled.
  29289. */
  29290. /**
  29291. * Sets wether the tone mapping effect is enabled.
  29292. */
  29293. toneMappingEnabled: boolean;
  29294. private _toneMappingType;
  29295. /**
  29296. * Gets the type of tone mapping effect.
  29297. */
  29298. /**
  29299. * Sets the type of tone mapping effect used in BabylonJS.
  29300. */
  29301. toneMappingType: number;
  29302. protected _contrast: number;
  29303. /**
  29304. * Gets the contrast used in the effect.
  29305. */
  29306. /**
  29307. * Sets the contrast used in the effect.
  29308. */
  29309. contrast: number;
  29310. /**
  29311. * Vignette stretch size.
  29312. */
  29313. vignetteStretch: number;
  29314. /**
  29315. * Vignette centre X Offset.
  29316. */
  29317. vignetteCentreX: number;
  29318. /**
  29319. * Vignette centre Y Offset.
  29320. */
  29321. vignetteCentreY: number;
  29322. /**
  29323. * Vignette weight or intensity of the vignette effect.
  29324. */
  29325. vignetteWeight: number;
  29326. /**
  29327. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29328. * if vignetteEnabled is set to true.
  29329. */
  29330. vignetteColor: Color4;
  29331. /**
  29332. * Camera field of view used by the Vignette effect.
  29333. */
  29334. vignetteCameraFov: number;
  29335. private _vignetteBlendMode;
  29336. /**
  29337. * Gets the vignette blend mode allowing different kind of effect.
  29338. */
  29339. /**
  29340. * Sets the vignette blend mode allowing different kind of effect.
  29341. */
  29342. vignetteBlendMode: number;
  29343. private _vignetteEnabled;
  29344. /**
  29345. * Gets wether the vignette effect is enabled.
  29346. */
  29347. /**
  29348. * Sets wether the vignette effect is enabled.
  29349. */
  29350. vignetteEnabled: boolean;
  29351. private _applyByPostProcess;
  29352. /**
  29353. * Gets wether the image processing is applied through a post process or not.
  29354. */
  29355. /**
  29356. * Sets wether the image processing is applied through a post process or not.
  29357. */
  29358. applyByPostProcess: boolean;
  29359. private _isEnabled;
  29360. /**
  29361. * Gets wether the image processing is enabled or not.
  29362. */
  29363. /**
  29364. * Sets wether the image processing is enabled or not.
  29365. */
  29366. isEnabled: boolean;
  29367. /**
  29368. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29369. */
  29370. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29371. /**
  29372. * Method called each time the image processing information changes requires to recompile the effect.
  29373. */
  29374. protected _updateParameters(): void;
  29375. /**
  29376. * Gets the current class name.
  29377. * @return "ImageProcessingConfiguration"
  29378. */
  29379. getClassName(): string;
  29380. /**
  29381. * Prepare the list of uniforms associated with the Image Processing effects.
  29382. * @param uniforms The list of uniforms used in the effect
  29383. * @param defines the list of defines currently in use
  29384. */
  29385. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29386. /**
  29387. * Prepare the list of samplers associated with the Image Processing effects.
  29388. * @param samplersList The list of uniforms used in the effect
  29389. * @param defines the list of defines currently in use
  29390. */
  29391. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29392. /**
  29393. * Prepare the list of defines associated to the shader.
  29394. * @param defines the list of defines to complete
  29395. * @param forPostProcess Define if we are currently in post process mode or not
  29396. */
  29397. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29398. /**
  29399. * Returns true if all the image processing information are ready.
  29400. * @returns True if ready, otherwise, false
  29401. */
  29402. isReady(): boolean;
  29403. /**
  29404. * Binds the image processing to the shader.
  29405. * @param effect The effect to bind to
  29406. * @param aspectRatio Define the current aspect ratio of the effect
  29407. */
  29408. bind(effect: Effect, aspectRatio?: number): void;
  29409. /**
  29410. * Clones the current image processing instance.
  29411. * @return The cloned image processing
  29412. */
  29413. clone(): ImageProcessingConfiguration;
  29414. /**
  29415. * Serializes the current image processing instance to a json representation.
  29416. * @return a JSON representation
  29417. */
  29418. serialize(): any;
  29419. /**
  29420. * Parses the image processing from a json representation.
  29421. * @param source the JSON source to parse
  29422. * @return The parsed image processing
  29423. */
  29424. static Parse(source: any): ImageProcessingConfiguration;
  29425. private static _VIGNETTEMODE_MULTIPLY;
  29426. private static _VIGNETTEMODE_OPAQUE;
  29427. /**
  29428. * Used to apply the vignette as a mix with the pixel color.
  29429. */
  29430. static readonly VIGNETTEMODE_MULTIPLY: number;
  29431. /**
  29432. * Used to apply the vignette as a replacement of the pixel color.
  29433. */
  29434. static readonly VIGNETTEMODE_OPAQUE: number;
  29435. }
  29436. }
  29437. declare module BABYLON {
  29438. /**
  29439. * This represents all the required information to add a fresnel effect on a material:
  29440. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29441. */
  29442. export class FresnelParameters {
  29443. private _isEnabled;
  29444. /**
  29445. * Define if the fresnel effect is enable or not.
  29446. */
  29447. isEnabled: boolean;
  29448. /**
  29449. * Define the color used on edges (grazing angle)
  29450. */
  29451. leftColor: Color3;
  29452. /**
  29453. * Define the color used on center
  29454. */
  29455. rightColor: Color3;
  29456. /**
  29457. * Define bias applied to computed fresnel term
  29458. */
  29459. bias: number;
  29460. /**
  29461. * Defined the power exponent applied to fresnel term
  29462. */
  29463. power: number;
  29464. /**
  29465. * Clones the current fresnel and its valuues
  29466. * @returns a clone fresnel configuration
  29467. */
  29468. clone(): FresnelParameters;
  29469. /**
  29470. * Serializes the current fresnel parameters to a JSON representation.
  29471. * @return the JSON serialization
  29472. */
  29473. serialize(): any;
  29474. /**
  29475. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29476. * @param parsedFresnelParameters Define the JSON representation
  29477. * @returns the parsed parameters
  29478. */
  29479. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29480. }
  29481. }
  29482. declare module BABYLON {
  29483. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29484. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29485. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29486. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29487. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29488. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29489. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29490. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29491. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29492. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29493. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29494. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29495. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29496. /**
  29497. * Decorator used to define property that can be serialized as reference to a camera
  29498. * @param sourceName defines the name of the property to decorate
  29499. */
  29500. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29501. /**
  29502. * Class used to help serialization objects
  29503. */
  29504. export class SerializationHelper {
  29505. /** hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29506. /** hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29507. /** hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29508. /** hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29509. /**
  29510. * Appends the serialized animations from the source animations
  29511. * @param source Source containing the animations
  29512. * @param destination Target to store the animations
  29513. */
  29514. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29515. /**
  29516. * Static function used to serialized a specific entity
  29517. * @param entity defines the entity to serialize
  29518. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29519. * @returns a JSON compatible object representing the serialization of the entity
  29520. */
  29521. static Serialize<T>(entity: T, serializationObject?: any): any;
  29522. /**
  29523. * Creates a new entity from a serialization data object
  29524. * @param creationFunction defines a function used to instanciated the new entity
  29525. * @param source defines the source serialization data
  29526. * @param scene defines the hosting scene
  29527. * @param rootUrl defines the root url for resources
  29528. * @returns a new entity
  29529. */
  29530. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29531. /**
  29532. * Clones an object
  29533. * @param creationFunction defines the function used to instanciate the new object
  29534. * @param source defines the source object
  29535. * @returns the cloned object
  29536. */
  29537. static Clone<T>(creationFunction: () => T, source: T): T;
  29538. /**
  29539. * Instanciates a new object based on a source one (some data will be shared between both object)
  29540. * @param creationFunction defines the function used to instanciate the new object
  29541. * @param source defines the source object
  29542. * @returns the new object
  29543. */
  29544. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29545. }
  29546. }
  29547. declare module BABYLON {
  29548. /**
  29549. * This is the base class of all the camera used in the application.
  29550. * @see http://doc.babylonjs.com/features/cameras
  29551. */
  29552. export class Camera extends Node {
  29553. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29554. /**
  29555. * This is the default projection mode used by the cameras.
  29556. * It helps recreating a feeling of perspective and better appreciate depth.
  29557. * This is the best way to simulate real life cameras.
  29558. */
  29559. static readonly PERSPECTIVE_CAMERA: number;
  29560. /**
  29561. * This helps creating camera with an orthographic mode.
  29562. * 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.
  29563. */
  29564. static readonly ORTHOGRAPHIC_CAMERA: number;
  29565. /**
  29566. * This is the default FOV mode for perspective cameras.
  29567. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29568. */
  29569. static readonly FOVMODE_VERTICAL_FIXED: number;
  29570. /**
  29571. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29572. */
  29573. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29574. /**
  29575. * This specifies ther is no need for a camera rig.
  29576. * Basically only one eye is rendered corresponding to the camera.
  29577. */
  29578. static readonly RIG_MODE_NONE: number;
  29579. /**
  29580. * Simulates a camera Rig with one blue eye and one red eye.
  29581. * This can be use with 3d blue and red glasses.
  29582. */
  29583. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29584. /**
  29585. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29586. */
  29587. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29588. /**
  29589. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29590. */
  29591. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29592. /**
  29593. * Defines that both eyes of the camera will be rendered over under each other.
  29594. */
  29595. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29596. /**
  29597. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29598. */
  29599. static readonly RIG_MODE_VR: number;
  29600. /**
  29601. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29602. */
  29603. static readonly RIG_MODE_WEBVR: number;
  29604. /**
  29605. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29606. */
  29607. static readonly RIG_MODE_CUSTOM: number;
  29608. /**
  29609. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29610. */
  29611. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29612. /**
  29613. * Define the input manager associated with the camera.
  29614. */
  29615. inputs: CameraInputsManager<Camera>;
  29616. /** @hidden */ position: Vector3;
  29617. /**
  29618. * Define the current local position of the camera in the scene
  29619. */
  29620. position: Vector3;
  29621. /**
  29622. * The vector the camera should consider as up.
  29623. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29624. */
  29625. upVector: Vector3;
  29626. /**
  29627. * Define the current limit on the left side for an orthographic camera
  29628. * In scene unit
  29629. */
  29630. orthoLeft: Nullable<number>;
  29631. /**
  29632. * Define the current limit on the right side for an orthographic camera
  29633. * In scene unit
  29634. */
  29635. orthoRight: Nullable<number>;
  29636. /**
  29637. * Define the current limit on the bottom side for an orthographic camera
  29638. * In scene unit
  29639. */
  29640. orthoBottom: Nullable<number>;
  29641. /**
  29642. * Define the current limit on the top side for an orthographic camera
  29643. * In scene unit
  29644. */
  29645. orthoTop: Nullable<number>;
  29646. /**
  29647. * Field Of View is set in Radians. (default is 0.8)
  29648. */
  29649. fov: number;
  29650. /**
  29651. * Define the minimum distance the camera can see from.
  29652. * This is important to note that the depth buffer are not infinite and the closer it starts
  29653. * the more your scene might encounter depth fighting issue.
  29654. */
  29655. minZ: number;
  29656. /**
  29657. * Define the maximum distance the camera can see to.
  29658. * This is important to note that the depth buffer are not infinite and the further it end
  29659. * the more your scene might encounter depth fighting issue.
  29660. */
  29661. maxZ: number;
  29662. /**
  29663. * Define the default inertia of the camera.
  29664. * This helps giving a smooth feeling to the camera movement.
  29665. */
  29666. inertia: number;
  29667. /**
  29668. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  29669. */
  29670. mode: number;
  29671. /**
  29672. * Define wether the camera is intermediate.
  29673. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29674. */
  29675. isIntermediate: boolean;
  29676. /**
  29677. * Define the viewport of the camera.
  29678. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29679. */
  29680. viewport: Viewport;
  29681. /**
  29682. * Restricts the camera to viewing objects with the same layerMask.
  29683. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29684. */
  29685. layerMask: number;
  29686. /**
  29687. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29688. */
  29689. fovMode: number;
  29690. /**
  29691. * Rig mode of the camera.
  29692. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29693. * This is normally controlled byt the camera themselves as internal use.
  29694. */
  29695. cameraRigMode: number;
  29696. /**
  29697. * Defines the distance between both "eyes" in case of a RIG
  29698. */
  29699. interaxialDistance: number;
  29700. /**
  29701. * Defines if stereoscopic rendering is done side by side or over under.
  29702. */
  29703. isStereoscopicSideBySide: boolean;
  29704. /**
  29705. * 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
  29706. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29707. * else in the scene.
  29708. */
  29709. customRenderTargets: RenderTargetTexture[];
  29710. /**
  29711. * When set, the camera will render to this render target instead of the default canvas
  29712. */
  29713. outputRenderTarget: Nullable<RenderTargetTexture>;
  29714. /**
  29715. * Observable triggered when the camera view matrix has changed.
  29716. */
  29717. onViewMatrixChangedObservable: Observable<Camera>;
  29718. /**
  29719. * Observable triggered when the camera Projection matrix has changed.
  29720. */
  29721. onProjectionMatrixChangedObservable: Observable<Camera>;
  29722. /**
  29723. * Observable triggered when the inputs have been processed.
  29724. */
  29725. onAfterCheckInputsObservable: Observable<Camera>;
  29726. /**
  29727. * Observable triggered when reset has been called and applied to the camera.
  29728. */
  29729. onRestoreStateObservable: Observable<Camera>;
  29730. /** @hidden */ cameraRigParams: any;
  29731. /** @hidden */ rigCameras: Camera[];
  29732. /** @hidden */ rigPostProcess: Nullable<PostProcess>;
  29733. protected _webvrViewMatrix: Matrix;
  29734. /** @hidden */ skipRendering: boolean;
  29735. /** @hidden */ projectionMatrix: Matrix;
  29736. /** @hidden */ postProcesses: Nullable<PostProcess>[];
  29737. /** @hidden */ activeMeshes: SmartArray<AbstractMesh>;
  29738. protected _globalPosition: Vector3;
  29739. /** hidden */ computedViewMatrix: Matrix;
  29740. private _doNotComputeProjectionMatrix;
  29741. private _transformMatrix;
  29742. private _frustumPlanes;
  29743. private _refreshFrustumPlanes;
  29744. private _storedFov;
  29745. private _stateStored;
  29746. /**
  29747. * Instantiates a new camera object.
  29748. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29749. * @see http://doc.babylonjs.com/features/cameras
  29750. * @param name Defines the name of the camera in the scene
  29751. * @param position Defines the position of the camera
  29752. * @param scene Defines the scene the camera belongs too
  29753. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29754. */
  29755. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29756. /**
  29757. * Store current camera state (fov, position, etc..)
  29758. * @returns the camera
  29759. */
  29760. storeState(): Camera;
  29761. /**
  29762. * Restores the camera state values if it has been stored. You must call storeState() first
  29763. */
  29764. protected _restoreStateValues(): boolean;
  29765. /**
  29766. * Restored camera state. You must call storeState() first.
  29767. * @returns true if restored and false otherwise
  29768. */
  29769. restoreState(): boolean;
  29770. /**
  29771. * Gets the class name of the camera.
  29772. * @returns the class name
  29773. */
  29774. getClassName(): string;
  29775. /** @hidden */ protected readonly _isCamera: boolean;
  29776. /**
  29777. * Gets a string representation of the camera useful for debug purpose.
  29778. * @param fullDetails Defines that a more verboe level of logging is required
  29779. * @returns the string representation
  29780. */
  29781. toString(fullDetails?: boolean): string;
  29782. /**
  29783. * Gets the current world space position of the camera.
  29784. */
  29785. readonly globalPosition: Vector3;
  29786. /**
  29787. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29788. * @returns the active meshe list
  29789. */
  29790. getActiveMeshes(): SmartArray<AbstractMesh>;
  29791. /**
  29792. * Check wether a mesh is part of the current active mesh list of the camera
  29793. * @param mesh Defines the mesh to check
  29794. * @returns true if active, false otherwise
  29795. */
  29796. isActiveMesh(mesh: Mesh): boolean;
  29797. /**
  29798. * Is this camera ready to be used/rendered
  29799. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29800. * @return true if the camera is ready
  29801. */
  29802. isReady(completeCheck?: boolean): boolean;
  29803. /** @hidden */ initCache(): void;
  29804. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  29805. /** @hidden */ isSynchronized(): boolean;
  29806. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  29807. /** @hidden */ isSynchronizedProjectionMatrix(): boolean;
  29808. /**
  29809. * Attach the input controls to a specific dom element to get the input from.
  29810. * @param element Defines the element the controls should be listened from
  29811. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29812. */
  29813. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29814. /**
  29815. * Detach the current controls from the specified dom element.
  29816. * @param element Defines the element to stop listening the inputs from
  29817. */
  29818. detachControl(element: HTMLElement): void;
  29819. /**
  29820. * Update the camera state according to the different inputs gathered during the frame.
  29821. */
  29822. update(): void;
  29823. /** @hidden */ checkInputs(): void;
  29824. /** @hidden */
  29825. readonly rigCameras: Camera[];
  29826. /**
  29827. * Gets the post process used by the rig cameras
  29828. */
  29829. readonly rigPostProcess: Nullable<PostProcess>;
  29830. /**
  29831. * Internal, gets the first post proces.
  29832. * @returns the first post process to be run on this camera.
  29833. */ getFirstPostProcess(): Nullable<PostProcess>;
  29834. private _cascadePostProcessesToRigCams;
  29835. /**
  29836. * Attach a post process to the camera.
  29837. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29838. * @param postProcess The post process to attach to the camera
  29839. * @param insertAt The position of the post process in case several of them are in use in the scene
  29840. * @returns the position the post process has been inserted at
  29841. */
  29842. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29843. /**
  29844. * Detach a post process to the camera.
  29845. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29846. * @param postProcess The post process to detach from the camera
  29847. */
  29848. detachPostProcess(postProcess: PostProcess): void;
  29849. /**
  29850. * Gets the current world matrix of the camera
  29851. */
  29852. getWorldMatrix(): Matrix;
  29853. /** @hidden */ getViewMatrix(): Matrix;
  29854. /**
  29855. * Gets the current view matrix of the camera.
  29856. * @param force forces the camera to recompute the matrix without looking at the cached state
  29857. * @returns the view matrix
  29858. */
  29859. getViewMatrix(force?: boolean): Matrix;
  29860. /**
  29861. * Freeze the projection matrix.
  29862. * It will prevent the cache check of the camera projection compute and can speed up perf
  29863. * if no parameter of the camera are meant to change
  29864. * @param projection Defines manually a projection if necessary
  29865. */
  29866. freezeProjectionMatrix(projection?: Matrix): void;
  29867. /**
  29868. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29869. */
  29870. unfreezeProjectionMatrix(): void;
  29871. /**
  29872. * Gets the current projection matrix of the camera.
  29873. * @param force forces the camera to recompute the matrix without looking at the cached state
  29874. * @returns the projection matrix
  29875. */
  29876. getProjectionMatrix(force?: boolean): Matrix;
  29877. /**
  29878. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29879. * @returns a Matrix
  29880. */
  29881. getTransformationMatrix(): Matrix;
  29882. private _updateFrustumPlanes;
  29883. /**
  29884. * Checks if a cullable object (mesh...) is in the camera frustum
  29885. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29886. * @param target The object to check
  29887. * @returns true if the object is in frustum otherwise false
  29888. */
  29889. isInFrustum(target: ICullable): boolean;
  29890. /**
  29891. * Checks if a cullable object (mesh...) is in the camera frustum
  29892. * Unlike isInFrustum this cheks the full bounding box
  29893. * @param target The object to check
  29894. * @returns true if the object is in frustum otherwise false
  29895. */
  29896. isCompletelyInFrustum(target: ICullable): boolean;
  29897. /**
  29898. * Gets a ray in the forward direction from the camera.
  29899. * @param length Defines the length of the ray to create
  29900. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29901. * @param origin Defines the start point of the ray which defaults to the camera position
  29902. * @returns the forward ray
  29903. */
  29904. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29905. /**
  29906. * Releases resources associated with this node.
  29907. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29908. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29909. */
  29910. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29911. /** @hidden */ isLeftCamera: boolean;
  29912. /**
  29913. * Gets the left camera of a rig setup in case of Rigged Camera
  29914. */
  29915. readonly isLeftCamera: boolean;
  29916. /** @hidden */ isRightCamera: boolean;
  29917. /**
  29918. * Gets the right camera of a rig setup in case of Rigged Camera
  29919. */
  29920. readonly isRightCamera: boolean;
  29921. /**
  29922. * Gets the left camera of a rig setup in case of Rigged Camera
  29923. */
  29924. readonly leftCamera: Nullable<FreeCamera>;
  29925. /**
  29926. * Gets the right camera of a rig setup in case of Rigged Camera
  29927. */
  29928. readonly rightCamera: Nullable<FreeCamera>;
  29929. /**
  29930. * Gets the left camera target of a rig setup in case of Rigged Camera
  29931. * @returns the target position
  29932. */
  29933. getLeftTarget(): Nullable<Vector3>;
  29934. /**
  29935. * Gets the right camera target of a rig setup in case of Rigged Camera
  29936. * @returns the target position
  29937. */
  29938. getRightTarget(): Nullable<Vector3>;
  29939. /**
  29940. * @hidden
  29941. */
  29942. setCameraRigMode(mode: number, rigParams: any): void;
  29943. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  29944. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29945. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  29946. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29947. /** @hidden */ getVRProjectionMatrix(): Matrix;
  29948. protected _updateCameraRotationMatrix(): void;
  29949. protected _updateWebVRCameraRotationMatrix(): void;
  29950. /**
  29951. * This function MUST be overwritten by the different WebVR cameras available.
  29952. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29953. * @hidden
  29954. */ getWebVRProjectionMatrix(): Matrix;
  29955. /**
  29956. * This function MUST be overwritten by the different WebVR cameras available.
  29957. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29958. * @hidden
  29959. */ getWebVRViewMatrix(): Matrix;
  29960. /** @hidden */
  29961. setCameraRigParameter(name: string, value: any): void;
  29962. /**
  29963. * needs to be overridden by children so sub has required properties to be copied
  29964. * @hidden
  29965. */
  29966. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29967. /**
  29968. * May need to be overridden by children
  29969. * @hidden
  29970. */ updateRigCameras(): void;
  29971. /** @hidden */ setupInputs(): void;
  29972. /**
  29973. * Serialiaze the camera setup to a json represention
  29974. * @returns the JSON representation
  29975. */
  29976. serialize(): any;
  29977. /**
  29978. * Clones the current camera.
  29979. * @param name The cloned camera name
  29980. * @returns the cloned camera
  29981. */
  29982. clone(name: string): Camera;
  29983. /**
  29984. * Gets the direction of the camera relative to a given local axis.
  29985. * @param localAxis Defines the reference axis to provide a relative direction.
  29986. * @return the direction
  29987. */
  29988. getDirection(localAxis: Vector3): Vector3;
  29989. /**
  29990. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29991. * @param localAxis Defines the reference axis to provide a relative direction.
  29992. * @param result Defines the vector to store the result in
  29993. */
  29994. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29995. /**
  29996. * Gets a camera constructor for a given camera type
  29997. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29998. * @param name The name of the camera the result will be able to instantiate
  29999. * @param scene The scene the result will construct the camera in
  30000. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30001. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30002. * @returns a factory method to construc the camera
  30003. */
  30004. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30005. /**
  30006. * Compute the world matrix of the camera.
  30007. * @returns the camera workd matrix
  30008. */
  30009. computeWorldMatrix(): Matrix;
  30010. /**
  30011. * Parse a JSON and creates the camera from the parsed information
  30012. * @param parsedCamera The JSON to parse
  30013. * @param scene The scene to instantiate the camera in
  30014. * @returns the newly constructed camera
  30015. */
  30016. static Parse(parsedCamera: any, scene: Scene): Camera;
  30017. }
  30018. }
  30019. declare module BABYLON {
  30020. /**
  30021. * Interface for any object that can request an animation frame
  30022. */
  30023. export interface ICustomAnimationFrameRequester {
  30024. /**
  30025. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30026. */
  30027. renderFunction?: Function;
  30028. /**
  30029. * Called to request the next frame to render to
  30030. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30031. */
  30032. requestAnimationFrame: Function;
  30033. /**
  30034. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30035. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30036. */
  30037. requestID?: number;
  30038. }
  30039. /**
  30040. * Interface containing an array of animations
  30041. */
  30042. export interface IAnimatable {
  30043. /**
  30044. * Array of animations
  30045. */
  30046. animations: Array<Animation>;
  30047. }
  30048. /** Interface used by value gradients (color, factor, ...) */
  30049. export interface IValueGradient {
  30050. /**
  30051. * Gets or sets the gradient value (between 0 and 1)
  30052. */
  30053. gradient: number;
  30054. }
  30055. /** Class used to store color4 gradient */
  30056. export class ColorGradient implements IValueGradient {
  30057. /**
  30058. * Gets or sets the gradient value (between 0 and 1)
  30059. */
  30060. gradient: number;
  30061. /**
  30062. * Gets or sets first associated color
  30063. */
  30064. color1: Color4;
  30065. /**
  30066. * Gets or sets second associated color
  30067. */
  30068. color2?: Color4;
  30069. /**
  30070. * Will get a color picked randomly between color1 and color2.
  30071. * If color2 is undefined then color1 will be used
  30072. * @param result defines the target Color4 to store the result in
  30073. */
  30074. getColorToRef(result: Color4): void;
  30075. }
  30076. /** Class used to store color 3 gradient */
  30077. export class Color3Gradient implements IValueGradient {
  30078. /**
  30079. * Gets or sets the gradient value (between 0 and 1)
  30080. */
  30081. gradient: number;
  30082. /**
  30083. * Gets or sets the associated color
  30084. */
  30085. color: Color3;
  30086. }
  30087. /** Class used to store factor gradient */
  30088. export class FactorGradient implements IValueGradient {
  30089. /**
  30090. * Gets or sets the gradient value (between 0 and 1)
  30091. */
  30092. gradient: number;
  30093. /**
  30094. * Gets or sets first associated factor
  30095. */
  30096. factor1: number;
  30097. /**
  30098. * Gets or sets second associated factor
  30099. */
  30100. factor2?: number;
  30101. /**
  30102. * Will get a number picked randomly between factor1 and factor2.
  30103. * If factor2 is undefined then factor1 will be used
  30104. * @returns the picked number
  30105. */
  30106. getFactor(): number;
  30107. }
  30108. /**
  30109. * @ignore
  30110. * Application error to support additional information when loading a file
  30111. */
  30112. export class LoadFileError extends Error {
  30113. /** defines the optional web request */
  30114. request?: WebRequest | undefined;
  30115. private static _setPrototypeOf;
  30116. /**
  30117. * Creates a new LoadFileError
  30118. * @param message defines the message of the error
  30119. * @param request defines the optional web request
  30120. */
  30121. constructor(message: string,
  30122. /** defines the optional web request */
  30123. request?: WebRequest | undefined);
  30124. }
  30125. /**
  30126. * Class used to define a retry strategy when error happens while loading assets
  30127. */
  30128. export class RetryStrategy {
  30129. /**
  30130. * Function used to defines an exponential back off strategy
  30131. * @param maxRetries defines the maximum number of retries (3 by default)
  30132. * @param baseInterval defines the interval between retries
  30133. * @returns the strategy function to use
  30134. */
  30135. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30136. }
  30137. /**
  30138. * File request interface
  30139. */
  30140. export interface IFileRequest {
  30141. /**
  30142. * Raised when the request is complete (success or error).
  30143. */
  30144. onCompleteObservable: Observable<IFileRequest>;
  30145. /**
  30146. * Aborts the request for a file.
  30147. */
  30148. abort: () => void;
  30149. }
  30150. /**
  30151. * Class containing a set of static utilities functions
  30152. */
  30153. export class Tools {
  30154. /**
  30155. * Gets or sets the base URL to use to load assets
  30156. */
  30157. static BaseUrl: string;
  30158. /**
  30159. * Enable/Disable Custom HTTP Request Headers globally.
  30160. * default = false
  30161. * @see CustomRequestHeaders
  30162. */
  30163. static UseCustomRequestHeaders: boolean;
  30164. /**
  30165. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30166. * i.e. when loading files, where the server/service expects an Authorization header
  30167. */
  30168. static CustomRequestHeaders: {
  30169. [key: string]: string;
  30170. };
  30171. /**
  30172. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30173. */
  30174. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30175. /**
  30176. * Default behaviour for cors in the application.
  30177. * It can be a string if the expected behavior is identical in the entire app.
  30178. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30179. */
  30180. static CorsBehavior: string | ((url: string | string[]) => string);
  30181. /**
  30182. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30183. * @ignorenaming
  30184. */
  30185. static UseFallbackTexture: boolean;
  30186. /**
  30187. * Use this object to register external classes like custom textures or material
  30188. * to allow the laoders to instantiate them
  30189. */
  30190. static RegisteredExternalClasses: {
  30191. [key: string]: Object;
  30192. };
  30193. /**
  30194. * Texture content used if a texture cannot loaded
  30195. * @ignorenaming
  30196. */
  30197. static fallbackTexture: string;
  30198. /**
  30199. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30200. * @param u defines the coordinate on X axis
  30201. * @param v defines the coordinate on Y axis
  30202. * @param width defines the width of the source data
  30203. * @param height defines the height of the source data
  30204. * @param pixels defines the source byte array
  30205. * @param color defines the output color
  30206. */
  30207. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30208. /**
  30209. * Interpolates between a and b via alpha
  30210. * @param a The lower value (returned when alpha = 0)
  30211. * @param b The upper value (returned when alpha = 1)
  30212. * @param alpha The interpolation-factor
  30213. * @return The mixed value
  30214. */
  30215. static Mix(a: number, b: number, alpha: number): number;
  30216. /**
  30217. * Tries to instantiate a new object from a given class name
  30218. * @param className defines the class name to instantiate
  30219. * @returns the new object or null if the system was not able to do the instantiation
  30220. */
  30221. static Instantiate(className: string): any;
  30222. /**
  30223. * Provides a slice function that will work even on IE
  30224. * @param data defines the array to slice
  30225. * @param start defines the start of the data (optional)
  30226. * @param end defines the end of the data (optional)
  30227. * @returns the new sliced array
  30228. */
  30229. static Slice<T>(data: T, start?: number, end?: number): T;
  30230. /**
  30231. * Polyfill for setImmediate
  30232. * @param action defines the action to execute after the current execution block
  30233. */
  30234. static SetImmediate(action: () => void): void;
  30235. /**
  30236. * Function indicating if a number is an exponent of 2
  30237. * @param value defines the value to test
  30238. * @returns true if the value is an exponent of 2
  30239. */
  30240. static IsExponentOfTwo(value: number): boolean;
  30241. private static _tmpFloatArray;
  30242. /**
  30243. * Returns the nearest 32-bit single precision float representation of a Number
  30244. * @param value A Number. If the parameter is of a different type, it will get converted
  30245. * to a number or to NaN if it cannot be converted
  30246. * @returns number
  30247. */
  30248. static FloatRound(value: number): number;
  30249. /**
  30250. * Find the next highest power of two.
  30251. * @param x Number to start search from.
  30252. * @return Next highest power of two.
  30253. */
  30254. static CeilingPOT(x: number): number;
  30255. /**
  30256. * Find the next lowest power of two.
  30257. * @param x Number to start search from.
  30258. * @return Next lowest power of two.
  30259. */
  30260. static FloorPOT(x: number): number;
  30261. /**
  30262. * Find the nearest power of two.
  30263. * @param x Number to start search from.
  30264. * @return Next nearest power of two.
  30265. */
  30266. static NearestPOT(x: number): number;
  30267. /**
  30268. * Get the closest exponent of two
  30269. * @param value defines the value to approximate
  30270. * @param max defines the maximum value to return
  30271. * @param mode defines how to define the closest value
  30272. * @returns closest exponent of two of the given value
  30273. */
  30274. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30275. /**
  30276. * Extracts the filename from a path
  30277. * @param path defines the path to use
  30278. * @returns the filename
  30279. */
  30280. static GetFilename(path: string): string;
  30281. /**
  30282. * Extracts the "folder" part of a path (everything before the filename).
  30283. * @param uri The URI to extract the info from
  30284. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30285. * @returns The "folder" part of the path
  30286. */
  30287. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30288. /**
  30289. * Extracts text content from a DOM element hierarchy
  30290. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30291. */
  30292. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30293. /**
  30294. * Convert an angle in radians to degrees
  30295. * @param angle defines the angle to convert
  30296. * @returns the angle in degrees
  30297. */
  30298. static ToDegrees(angle: number): number;
  30299. /**
  30300. * Convert an angle in degrees to radians
  30301. * @param angle defines the angle to convert
  30302. * @returns the angle in radians
  30303. */
  30304. static ToRadians(angle: number): number;
  30305. /**
  30306. * Encode a buffer to a base64 string
  30307. * @param buffer defines the buffer to encode
  30308. * @returns the encoded string
  30309. */
  30310. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30311. /**
  30312. * Extracts minimum and maximum values from a list of indexed positions
  30313. * @param positions defines the positions to use
  30314. * @param indices defines the indices to the positions
  30315. * @param indexStart defines the start index
  30316. * @param indexCount defines the end index
  30317. * @param bias defines bias value to add to the result
  30318. * @return minimum and maximum values
  30319. */
  30320. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30321. minimum: Vector3;
  30322. maximum: Vector3;
  30323. };
  30324. /**
  30325. * Extracts minimum and maximum values from a list of positions
  30326. * @param positions defines the positions to use
  30327. * @param start defines the start index in the positions array
  30328. * @param count defines the number of positions to handle
  30329. * @param bias defines bias value to add to the result
  30330. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30331. * @return minimum and maximum values
  30332. */
  30333. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30334. minimum: Vector3;
  30335. maximum: Vector3;
  30336. };
  30337. /**
  30338. * Returns an array if obj is not an array
  30339. * @param obj defines the object to evaluate as an array
  30340. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30341. * @returns either obj directly if obj is an array or a new array containing obj
  30342. */
  30343. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30344. /**
  30345. * Gets the pointer prefix to use
  30346. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30347. */
  30348. static GetPointerPrefix(): string;
  30349. /**
  30350. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30351. * @param func - the function to be called
  30352. * @param requester - the object that will request the next frame. Falls back to window.
  30353. * @returns frame number
  30354. */
  30355. static QueueNewFrame(func: () => void, requester?: any): number;
  30356. /**
  30357. * Ask the browser to promote the current element to fullscreen rendering mode
  30358. * @param element defines the DOM element to promote
  30359. */
  30360. static RequestFullscreen(element: HTMLElement): void;
  30361. /**
  30362. * Asks the browser to exit fullscreen mode
  30363. */
  30364. static ExitFullscreen(): void;
  30365. /**
  30366. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30367. * @param url define the url we are trying
  30368. * @param element define the dom element where to configure the cors policy
  30369. */
  30370. static SetCorsBehavior(url: string | string[], element: {
  30371. crossOrigin: string | null;
  30372. }): void;
  30373. /**
  30374. * Removes unwanted characters from an url
  30375. * @param url defines the url to clean
  30376. * @returns the cleaned url
  30377. */
  30378. static CleanUrl(url: string): string;
  30379. /**
  30380. * Gets or sets a function used to pre-process url before using them to load assets
  30381. */
  30382. static PreprocessUrl: (url: string) => string;
  30383. /**
  30384. * Loads an image as an HTMLImageElement.
  30385. * @param input url string, ArrayBuffer, or Blob to load
  30386. * @param onLoad callback called when the image successfully loads
  30387. * @param onError callback called when the image fails to load
  30388. * @param offlineProvider offline provider for caching
  30389. * @returns the HTMLImageElement of the loaded image
  30390. */
  30391. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30392. /**
  30393. * Loads a file
  30394. * @param url url string, ArrayBuffer, or Blob to load
  30395. * @param onSuccess callback called when the file successfully loads
  30396. * @param onProgress callback called while file is loading (if the server supports this mode)
  30397. * @param offlineProvider defines the offline provider for caching
  30398. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30399. * @param onError callback called when the file fails to load
  30400. * @returns a file request object
  30401. */
  30402. 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;
  30403. /**
  30404. * Load a script (identified by an url). When the url returns, the
  30405. * content of this file is added into a new script element, attached to the DOM (body element)
  30406. * @param scriptUrl defines the url of the script to laod
  30407. * @param onSuccess defines the callback called when the script is loaded
  30408. * @param onError defines the callback to call if an error occurs
  30409. * @param scriptId defines the id of the script element
  30410. */
  30411. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  30412. /**
  30413. * Load an asynchronous script (identified by an url). When the url returns, the
  30414. * content of this file is added into a new script element, attached to the DOM (body element)
  30415. * @param scriptUrl defines the url of the script to laod
  30416. * @param scriptId defines the id of the script element
  30417. * @returns a promise request object
  30418. */
  30419. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  30420. /**
  30421. * Loads a file from a blob
  30422. * @param fileToLoad defines the blob to use
  30423. * @param callback defines the callback to call when data is loaded
  30424. * @param progressCallback defines the callback to call during loading process
  30425. * @returns a file request object
  30426. */
  30427. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30428. /**
  30429. * Loads a file
  30430. * @param fileToLoad defines the file to load
  30431. * @param callback defines the callback to call when data is loaded
  30432. * @param progressCallBack defines the callback to call during loading process
  30433. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30434. * @returns a file request object
  30435. */
  30436. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30437. /**
  30438. * Creates a data url from a given string content
  30439. * @param content defines the content to convert
  30440. * @returns the new data url link
  30441. */
  30442. static FileAsURL(content: string): string;
  30443. /**
  30444. * Format the given number to a specific decimal format
  30445. * @param value defines the number to format
  30446. * @param decimals defines the number of decimals to use
  30447. * @returns the formatted string
  30448. */
  30449. static Format(value: number, decimals?: number): string;
  30450. /**
  30451. * Checks if a given vector is inside a specific range
  30452. * @param v defines the vector to test
  30453. * @param min defines the minimum range
  30454. * @param max defines the maximum range
  30455. */
  30456. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30457. /**
  30458. * Tries to copy an object by duplicating every property
  30459. * @param source defines the source object
  30460. * @param destination defines the target object
  30461. * @param doNotCopyList defines a list of properties to avoid
  30462. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30463. */
  30464. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30465. /**
  30466. * Gets a boolean indicating if the given object has no own property
  30467. * @param obj defines the object to test
  30468. * @returns true if object has no own property
  30469. */
  30470. static IsEmpty(obj: any): boolean;
  30471. /**
  30472. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  30473. * @param str Source string
  30474. * @param suffix Suffix to search for in the source string
  30475. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  30476. */
  30477. static EndsWith(str: string, suffix: string): boolean;
  30478. /**
  30479. * Function used to register events at window level
  30480. * @param events defines the events to register
  30481. */
  30482. static RegisterTopRootEvents(events: {
  30483. name: string;
  30484. handler: Nullable<(e: FocusEvent) => any>;
  30485. }[]): void;
  30486. /**
  30487. * Function used to unregister events from window level
  30488. * @param events defines the events to unregister
  30489. */
  30490. static UnregisterTopRootEvents(events: {
  30491. name: string;
  30492. handler: Nullable<(e: FocusEvent) => any>;
  30493. }[]): void;
  30494. /**
  30495. * @ignore
  30496. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  30497. /**
  30498. * Dumps the current bound framebuffer
  30499. * @param width defines the rendering width
  30500. * @param height defines the rendering height
  30501. * @param engine defines the hosting engine
  30502. * @param successCallback defines the callback triggered once the data are available
  30503. * @param mimeType defines the mime type of the result
  30504. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30505. */
  30506. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30507. /**
  30508. * Converts the canvas data to blob.
  30509. * This acts as a polyfill for browsers not supporting the to blob function.
  30510. * @param canvas Defines the canvas to extract the data from
  30511. * @param successCallback Defines the callback triggered once the data are available
  30512. * @param mimeType Defines the mime type of the result
  30513. */
  30514. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30515. /**
  30516. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30517. * @param successCallback defines the callback triggered once the data are available
  30518. * @param mimeType defines the mime type of the result
  30519. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30520. */
  30521. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30522. /**
  30523. * Downloads a blob in the browser
  30524. * @param blob defines the blob to download
  30525. * @param fileName defines the name of the downloaded file
  30526. */
  30527. static Download(blob: Blob, fileName: string): void;
  30528. /**
  30529. * Captures a screenshot of the current rendering
  30530. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30531. * @param engine defines the rendering engine
  30532. * @param camera defines the source camera
  30533. * @param size This parameter can be set to a single number or to an object with the
  30534. * following (optional) properties: precision, width, height. If a single number is passed,
  30535. * it will be used for both width and height. If an object is passed, the screenshot size
  30536. * will be derived from the parameters. The precision property is a multiplier allowing
  30537. * rendering at a higher or lower resolution
  30538. * @param successCallback defines the callback receives a single parameter which contains the
  30539. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30540. * src parameter of an <img> to display it
  30541. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30542. * Check your browser for supported MIME types
  30543. */
  30544. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30545. /**
  30546. * Generates an image screenshot from the specified camera.
  30547. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30548. * @param engine The engine to use for rendering
  30549. * @param camera The camera to use for rendering
  30550. * @param size This parameter can be set to a single number or to an object with the
  30551. * following (optional) properties: precision, width, height. If a single number is passed,
  30552. * it will be used for both width and height. If an object is passed, the screenshot size
  30553. * will be derived from the parameters. The precision property is a multiplier allowing
  30554. * rendering at a higher or lower resolution
  30555. * @param successCallback The callback receives a single parameter which contains the
  30556. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30557. * src parameter of an <img> to display it
  30558. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30559. * Check your browser for supported MIME types
  30560. * @param samples Texture samples (default: 1)
  30561. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30562. * @param fileName A name for for the downloaded file.
  30563. */
  30564. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30565. /**
  30566. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30567. * Be aware Math.random() could cause collisions, but:
  30568. * "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"
  30569. * @returns a pseudo random id
  30570. */
  30571. static RandomId(): string;
  30572. /**
  30573. * Test if the given uri is a base64 string
  30574. * @param uri The uri to test
  30575. * @return True if the uri is a base64 string or false otherwise
  30576. */
  30577. static IsBase64(uri: string): boolean;
  30578. /**
  30579. * Decode the given base64 uri.
  30580. * @param uri The uri to decode
  30581. * @return The decoded base64 data.
  30582. */
  30583. static DecodeBase64(uri: string): ArrayBuffer;
  30584. /**
  30585. * No log
  30586. */
  30587. static readonly NoneLogLevel: number;
  30588. /**
  30589. * Only message logs
  30590. */
  30591. static readonly MessageLogLevel: number;
  30592. /**
  30593. * Only warning logs
  30594. */
  30595. static readonly WarningLogLevel: number;
  30596. /**
  30597. * Only error logs
  30598. */
  30599. static readonly ErrorLogLevel: number;
  30600. /**
  30601. * All logs
  30602. */
  30603. static readonly AllLogLevel: number;
  30604. /**
  30605. * Gets a value indicating the number of loading errors
  30606. * @ignorenaming
  30607. */
  30608. static readonly errorsCount: number;
  30609. /**
  30610. * Callback called when a new log is added
  30611. */
  30612. static OnNewCacheEntry: (entry: string) => void;
  30613. /**
  30614. * Log a message to the console
  30615. * @param message defines the message to log
  30616. */
  30617. static Log(message: string): void;
  30618. /**
  30619. * Write a warning message to the console
  30620. * @param message defines the message to log
  30621. */
  30622. static Warn(message: string): void;
  30623. /**
  30624. * Write an error message to the console
  30625. * @param message defines the message to log
  30626. */
  30627. static Error(message: string): void;
  30628. /**
  30629. * Gets current log cache (list of logs)
  30630. */
  30631. static readonly LogCache: string;
  30632. /**
  30633. * Clears the log cache
  30634. */
  30635. static ClearLogCache(): void;
  30636. /**
  30637. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  30638. */
  30639. static LogLevels: number;
  30640. /**
  30641. * Checks if the loaded document was accessed via `file:`-Protocol.
  30642. * @returns boolean
  30643. */
  30644. static IsFileURL(): boolean;
  30645. /**
  30646. * Checks if the window object exists
  30647. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  30648. */
  30649. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  30650. /**
  30651. * No performance log
  30652. */
  30653. static readonly PerformanceNoneLogLevel: number;
  30654. /**
  30655. * Use user marks to log performance
  30656. */
  30657. static readonly PerformanceUserMarkLogLevel: number;
  30658. /**
  30659. * Log performance to the console
  30660. */
  30661. static readonly PerformanceConsoleLogLevel: number;
  30662. private static _performance;
  30663. /**
  30664. * Sets the current performance log level
  30665. */
  30666. static PerformanceLogLevel: number;
  30667. private static _StartPerformanceCounterDisabled;
  30668. private static _EndPerformanceCounterDisabled;
  30669. private static _StartUserMark;
  30670. private static _EndUserMark;
  30671. private static _StartPerformanceConsole;
  30672. private static _EndPerformanceConsole;
  30673. /**
  30674. * Starts a performance counter
  30675. */
  30676. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30677. /**
  30678. * Ends a specific performance coutner
  30679. */
  30680. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30681. /**
  30682. * Gets either window.performance.now() if supported or Date.now() else
  30683. */
  30684. static readonly Now: number;
  30685. /**
  30686. * This method will return the name of the class used to create the instance of the given object.
  30687. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30688. * @param object the object to get the class name from
  30689. * @param isType defines if the object is actually a type
  30690. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  30691. */
  30692. static GetClassName(object: any, isType?: boolean): string;
  30693. /**
  30694. * Gets the first element of an array satisfying a given predicate
  30695. * @param array defines the array to browse
  30696. * @param predicate defines the predicate to use
  30697. * @returns null if not found or the element
  30698. */
  30699. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30700. /**
  30701. * This method will return the name of the full name of the class, including its owning module (if any).
  30702. * 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).
  30703. * @param object the object to get the class name from
  30704. * @param isType defines if the object is actually a type
  30705. * @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.
  30706. * @ignorenaming
  30707. */
  30708. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30709. /**
  30710. * Returns a promise that resolves after the given amount of time.
  30711. * @param delay Number of milliseconds to delay
  30712. * @returns Promise that resolves after the given amount of time
  30713. */
  30714. static DelayAsync(delay: number): Promise<void>;
  30715. /**
  30716. * Gets the current gradient from an array of IValueGradient
  30717. * @param ratio defines the current ratio to get
  30718. * @param gradients defines the array of IValueGradient
  30719. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30720. */
  30721. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30722. }
  30723. /**
  30724. * This class is used to track a performance counter which is number based.
  30725. * The user has access to many properties which give statistics of different nature.
  30726. *
  30727. * The implementer can track two kinds of Performance Counter: time and count.
  30728. * 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.
  30729. * 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.
  30730. */
  30731. export class PerfCounter {
  30732. /**
  30733. * Gets or sets a global boolean to turn on and off all the counters
  30734. */
  30735. static Enabled: boolean;
  30736. /**
  30737. * Returns the smallest value ever
  30738. */
  30739. readonly min: number;
  30740. /**
  30741. * Returns the biggest value ever
  30742. */
  30743. readonly max: number;
  30744. /**
  30745. * Returns the average value since the performance counter is running
  30746. */
  30747. readonly average: number;
  30748. /**
  30749. * Returns the average value of the last second the counter was monitored
  30750. */
  30751. readonly lastSecAverage: number;
  30752. /**
  30753. * Returns the current value
  30754. */
  30755. readonly current: number;
  30756. /**
  30757. * Gets the accumulated total
  30758. */
  30759. readonly total: number;
  30760. /**
  30761. * Gets the total value count
  30762. */
  30763. readonly count: number;
  30764. /**
  30765. * Creates a new counter
  30766. */
  30767. constructor();
  30768. /**
  30769. * Call this method to start monitoring a new frame.
  30770. * 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.
  30771. */
  30772. fetchNewFrame(): void;
  30773. /**
  30774. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30775. * @param newCount the count value to add to the monitored count
  30776. * @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.
  30777. */
  30778. addCount(newCount: number, fetchResult: boolean): void;
  30779. /**
  30780. * Start monitoring this performance counter
  30781. */
  30782. beginMonitoring(): void;
  30783. /**
  30784. * Compute the time lapsed since the previous beginMonitoring() call.
  30785. * @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
  30786. */
  30787. endMonitoring(newFrame?: boolean): void;
  30788. private _fetchResult;
  30789. private _startMonitoringTime;
  30790. private _min;
  30791. private _max;
  30792. private _average;
  30793. private _current;
  30794. private _totalValueCount;
  30795. private _totalAccumulated;
  30796. private _lastSecAverage;
  30797. private _lastSecAccumulated;
  30798. private _lastSecTime;
  30799. private _lastSecValueCount;
  30800. }
  30801. /**
  30802. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30803. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30804. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30805. * @param name The name of the class, case should be preserved
  30806. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30807. */
  30808. export function className(name: string, module?: string): (target: Object) => void;
  30809. /**
  30810. * An implementation of a loop for asynchronous functions.
  30811. */
  30812. export class AsyncLoop {
  30813. /**
  30814. * Defines the number of iterations for the loop
  30815. */
  30816. iterations: number;
  30817. /**
  30818. * Defines the current index of the loop.
  30819. */
  30820. index: number;
  30821. private _done;
  30822. private _fn;
  30823. private _successCallback;
  30824. /**
  30825. * Constructor.
  30826. * @param iterations the number of iterations.
  30827. * @param func the function to run each iteration
  30828. * @param successCallback the callback that will be called upon succesful execution
  30829. * @param offset starting offset.
  30830. */
  30831. constructor(
  30832. /**
  30833. * Defines the number of iterations for the loop
  30834. */
  30835. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  30836. /**
  30837. * Execute the next iteration. Must be called after the last iteration was finished.
  30838. */
  30839. executeNext(): void;
  30840. /**
  30841. * Break the loop and run the success callback.
  30842. */
  30843. breakLoop(): void;
  30844. /**
  30845. * Create and run an async loop.
  30846. * @param iterations the number of iterations.
  30847. * @param fn the function to run each iteration
  30848. * @param successCallback the callback that will be called upon succesful execution
  30849. * @param offset starting offset.
  30850. * @returns the created async loop object
  30851. */
  30852. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  30853. /**
  30854. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30855. * @param iterations total number of iterations
  30856. * @param syncedIterations number of synchronous iterations in each async iteration.
  30857. * @param fn the function to call each iteration.
  30858. * @param callback a success call back that will be called when iterating stops.
  30859. * @param breakFunction a break condition (optional)
  30860. * @param timeout timeout settings for the setTimeout function. default - 0.
  30861. * @returns the created async loop object
  30862. */
  30863. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  30864. }
  30865. }
  30866. declare module BABYLON {
  30867. /** @hidden */
  30868. export interface ICollisionCoordinator {
  30869. createCollider(): Collider;
  30870. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30871. init(scene: Scene): void;
  30872. }
  30873. /** @hidden */
  30874. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  30875. private _scene;
  30876. private _scaledPosition;
  30877. private _scaledVelocity;
  30878. private _finalPosition;
  30879. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30880. createCollider(): Collider;
  30881. init(scene: Scene): void;
  30882. private _collideWithWorld;
  30883. }
  30884. }
  30885. declare module BABYLON {
  30886. /**
  30887. * This class defines the direct association between an animation and a target
  30888. */
  30889. export class TargetedAnimation {
  30890. /**
  30891. * Animation to perform
  30892. */
  30893. animation: Animation;
  30894. /**
  30895. * Target to animate
  30896. */
  30897. target: any;
  30898. }
  30899. /**
  30900. * Use this class to create coordinated animations on multiple targets
  30901. */
  30902. export class AnimationGroup implements IDisposable {
  30903. /** The name of the animation group */
  30904. name: string;
  30905. private _scene;
  30906. private _targetedAnimations;
  30907. private _animatables;
  30908. private _from;
  30909. private _to;
  30910. private _isStarted;
  30911. private _isPaused;
  30912. private _speedRatio;
  30913. /**
  30914. * Gets or sets the unique id of the node
  30915. */
  30916. uniqueId: number;
  30917. /**
  30918. * This observable will notify when one animation have ended
  30919. */
  30920. onAnimationEndObservable: Observable<TargetedAnimation>;
  30921. /**
  30922. * Observer raised when one animation loops
  30923. */
  30924. onAnimationLoopObservable: Observable<TargetedAnimation>;
  30925. /**
  30926. * This observable will notify when all animations have ended.
  30927. */
  30928. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  30929. /**
  30930. * This observable will notify when all animations have paused.
  30931. */
  30932. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  30933. /**
  30934. * This observable will notify when all animations are playing.
  30935. */
  30936. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  30937. /**
  30938. * Gets the first frame
  30939. */
  30940. readonly from: number;
  30941. /**
  30942. * Gets the last frame
  30943. */
  30944. readonly to: number;
  30945. /**
  30946. * Define if the animations are started
  30947. */
  30948. readonly isStarted: boolean;
  30949. /**
  30950. * Gets a value indicating that the current group is playing
  30951. */
  30952. readonly isPlaying: boolean;
  30953. /**
  30954. * Gets or sets the speed ratio to use for all animations
  30955. */
  30956. /**
  30957. * Gets or sets the speed ratio to use for all animations
  30958. */
  30959. speedRatio: number;
  30960. /**
  30961. * Gets the targeted animations for this animation group
  30962. */
  30963. readonly targetedAnimations: Array<TargetedAnimation>;
  30964. /**
  30965. * returning the list of animatables controlled by this animation group.
  30966. */
  30967. readonly animatables: Array<Animatable>;
  30968. /**
  30969. * Instantiates a new Animation Group.
  30970. * This helps managing several animations at once.
  30971. * @see http://doc.babylonjs.com/how_to/group
  30972. * @param name Defines the name of the group
  30973. * @param scene Defines the scene the group belongs to
  30974. */
  30975. constructor(
  30976. /** The name of the animation group */
  30977. name: string, scene?: Nullable<Scene>);
  30978. /**
  30979. * Add an animation (with its target) in the group
  30980. * @param animation defines the animation we want to add
  30981. * @param target defines the target of the animation
  30982. * @returns the TargetedAnimation object
  30983. */
  30984. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  30985. /**
  30986. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  30987. * It can add constant keys at begin or end
  30988. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  30989. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  30990. * @returns the animation group
  30991. */
  30992. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  30993. /**
  30994. * Start all animations on given targets
  30995. * @param loop defines if animations must loop
  30996. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  30997. * @param from defines the from key (optional)
  30998. * @param to defines the to key (optional)
  30999. * @returns the current animation group
  31000. */
  31001. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31002. /**
  31003. * Pause all animations
  31004. * @returns the animation group
  31005. */
  31006. pause(): AnimationGroup;
  31007. /**
  31008. * Play all animations to initial state
  31009. * This function will start() the animations if they were not started or will restart() them if they were paused
  31010. * @param loop defines if animations must loop
  31011. * @returns the animation group
  31012. */
  31013. play(loop?: boolean): AnimationGroup;
  31014. /**
  31015. * Reset all animations to initial state
  31016. * @returns the animation group
  31017. */
  31018. reset(): AnimationGroup;
  31019. /**
  31020. * Restart animations from key 0
  31021. * @returns the animation group
  31022. */
  31023. restart(): AnimationGroup;
  31024. /**
  31025. * Stop all animations
  31026. * @returns the animation group
  31027. */
  31028. stop(): AnimationGroup;
  31029. /**
  31030. * Set animation weight for all animatables
  31031. * @param weight defines the weight to use
  31032. * @return the animationGroup
  31033. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31034. */
  31035. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31036. /**
  31037. * Synchronize and normalize all animatables with a source animatable
  31038. * @param root defines the root animatable to synchronize with
  31039. * @return the animationGroup
  31040. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31041. */
  31042. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31043. /**
  31044. * Goes to a specific frame in this animation group
  31045. * @param frame the frame number to go to
  31046. * @return the animationGroup
  31047. */
  31048. goToFrame(frame: number): AnimationGroup;
  31049. /**
  31050. * Dispose all associated resources
  31051. */
  31052. dispose(): void;
  31053. private _checkAnimationGroupEnded;
  31054. /**
  31055. * Clone the current animation group and returns a copy
  31056. * @param newName defines the name of the new group
  31057. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31058. * @returns the new aniamtion group
  31059. */
  31060. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31061. /**
  31062. * Returns a new AnimationGroup object parsed from the source provided.
  31063. * @param parsedAnimationGroup defines the source
  31064. * @param scene defines the scene that will receive the animationGroup
  31065. * @returns a new AnimationGroup
  31066. */
  31067. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31068. /**
  31069. * Returns the string "AnimationGroup"
  31070. * @returns "AnimationGroup"
  31071. */
  31072. getClassName(): string;
  31073. /**
  31074. * Creates a detailled string about the object
  31075. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31076. * @returns a string representing the object
  31077. */
  31078. toString(fullDetails?: boolean): string;
  31079. }
  31080. }
  31081. declare module BABYLON {
  31082. /**
  31083. * Define an interface for all classes that will hold resources
  31084. */
  31085. export interface IDisposable {
  31086. /**
  31087. * Releases all held resources
  31088. */
  31089. dispose(): void;
  31090. }
  31091. /** Interface defining initialization parameters for Scene class */
  31092. export interface SceneOptions {
  31093. /**
  31094. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31095. * It will improve performance when the number of geometries becomes important.
  31096. */
  31097. useGeometryUniqueIdsMap?: boolean;
  31098. /**
  31099. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31100. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31101. */
  31102. useMaterialMeshMap?: boolean;
  31103. /**
  31104. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31105. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31106. */
  31107. useClonedMeshhMap?: boolean;
  31108. }
  31109. /**
  31110. * Represents a scene to be rendered by the engine.
  31111. * @see http://doc.babylonjs.com/features/scene
  31112. */
  31113. export class Scene extends AbstractScene implements IAnimatable {
  31114. private static _uniqueIdCounter;
  31115. /** The fog is deactivated */
  31116. static readonly FOGMODE_NONE: number;
  31117. /** The fog density is following an exponential function */
  31118. static readonly FOGMODE_EXP: number;
  31119. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31120. static readonly FOGMODE_EXP2: number;
  31121. /** The fog density is following a linear function. */
  31122. static readonly FOGMODE_LINEAR: number;
  31123. /**
  31124. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31125. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31126. */
  31127. static MinDeltaTime: number;
  31128. /**
  31129. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31130. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31131. */
  31132. static MaxDeltaTime: number;
  31133. /**
  31134. * Factory used to create the default material.
  31135. * @param name The name of the material to create
  31136. * @param scene The scene to create the material for
  31137. * @returns The default material
  31138. */
  31139. static DefaultMaterialFactory(scene: Scene): Material;
  31140. /**
  31141. * Factory used to create the a collision coordinator.
  31142. * @returns The collision coordinator
  31143. */
  31144. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31145. /** @hidden */ protected readonly _isScene: boolean;
  31146. /**
  31147. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31148. */
  31149. autoClear: boolean;
  31150. /**
  31151. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31152. */
  31153. autoClearDepthAndStencil: boolean;
  31154. /**
  31155. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31156. */
  31157. clearColor: Color4;
  31158. /**
  31159. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31160. */
  31161. ambientColor: Color3;
  31162. /**
  31163. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31164. * It should only be one of the following (if not the default embedded one):
  31165. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31166. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31167. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31168. * The material properties need to be setup according to the type of texture in use.
  31169. */
  31170. environmentBRDFTexture: BaseTexture;
  31171. /** @hidden */
  31172. protected _environmentTexture: Nullable<BaseTexture>;
  31173. /**
  31174. * Texture used in all pbr material as the reflection texture.
  31175. * As in the majority of the scene they are the same (exception for multi room and so on),
  31176. * this is easier to reference from here than from all the materials.
  31177. */
  31178. /**
  31179. * Texture used in all pbr material as the reflection texture.
  31180. * As in the majority of the scene they are the same (exception for multi room and so on),
  31181. * this is easier to set here than in all the materials.
  31182. */
  31183. environmentTexture: Nullable<BaseTexture>;
  31184. /** @hidden */
  31185. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31186. /**
  31187. * Default image processing configuration used either in the rendering
  31188. * Forward main pass or through the imageProcessingPostProcess if present.
  31189. * As in the majority of the scene they are the same (exception for multi camera),
  31190. * this is easier to reference from here than from all the materials and post process.
  31191. *
  31192. * No setter as we it is a shared configuration, you can set the values instead.
  31193. */
  31194. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31195. private _forceWireframe;
  31196. /**
  31197. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31198. */
  31199. forceWireframe: boolean;
  31200. private _forcePointsCloud;
  31201. /**
  31202. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31203. */
  31204. forcePointsCloud: boolean;
  31205. /**
  31206. * Gets or sets the active clipplane 1
  31207. */
  31208. clipPlane: Nullable<Plane>;
  31209. /**
  31210. * Gets or sets the active clipplane 2
  31211. */
  31212. clipPlane2: Nullable<Plane>;
  31213. /**
  31214. * Gets or sets the active clipplane 3
  31215. */
  31216. clipPlane3: Nullable<Plane>;
  31217. /**
  31218. * Gets or sets the active clipplane 4
  31219. */
  31220. clipPlane4: Nullable<Plane>;
  31221. /**
  31222. * Gets or sets a boolean indicating if animations are enabled
  31223. */
  31224. animationsEnabled: boolean;
  31225. private _animationPropertiesOverride;
  31226. /**
  31227. * Gets or sets the animation properties override
  31228. */
  31229. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31230. /**
  31231. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31232. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31233. */
  31234. useConstantAnimationDeltaTime: boolean;
  31235. /**
  31236. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31237. * Please note that it requires to run a ray cast through the scene on every frame
  31238. */
  31239. constantlyUpdateMeshUnderPointer: boolean;
  31240. /**
  31241. * Defines the HTML cursor to use when hovering over interactive elements
  31242. */
  31243. hoverCursor: string;
  31244. /**
  31245. * Defines the HTML default cursor to use (empty by default)
  31246. */
  31247. defaultCursor: string;
  31248. /**
  31249. * This is used to call preventDefault() on pointer down
  31250. * in order to block unwanted artifacts like system double clicks
  31251. */
  31252. preventDefaultOnPointerDown: boolean;
  31253. /**
  31254. * This is used to call preventDefault() on pointer up
  31255. * in order to block unwanted artifacts like system double clicks
  31256. */
  31257. preventDefaultOnPointerUp: boolean;
  31258. /**
  31259. * Gets or sets user defined metadata
  31260. */
  31261. metadata: any;
  31262. /**
  31263. * For internal use only. Please do not use.
  31264. */
  31265. reservedDataStore: any;
  31266. /**
  31267. * Gets the name of the plugin used to load this scene (null by default)
  31268. */
  31269. loadingPluginName: string;
  31270. /**
  31271. * Use this array to add regular expressions used to disable offline support for specific urls
  31272. */
  31273. disableOfflineSupportExceptionRules: RegExp[];
  31274. /**
  31275. * An event triggered when the scene is disposed.
  31276. */
  31277. onDisposeObservable: Observable<Scene>;
  31278. private _onDisposeObserver;
  31279. /** Sets a function to be executed when this scene is disposed. */
  31280. onDispose: () => void;
  31281. /**
  31282. * An event triggered before rendering the scene (right after animations and physics)
  31283. */
  31284. onBeforeRenderObservable: Observable<Scene>;
  31285. private _onBeforeRenderObserver;
  31286. /** Sets a function to be executed before rendering this scene */
  31287. beforeRender: Nullable<() => void>;
  31288. /**
  31289. * An event triggered after rendering the scene
  31290. */
  31291. onAfterRenderObservable: Observable<Scene>;
  31292. private _onAfterRenderObserver;
  31293. /** Sets a function to be executed after rendering this scene */
  31294. afterRender: Nullable<() => void>;
  31295. /**
  31296. * An event triggered before animating the scene
  31297. */
  31298. onBeforeAnimationsObservable: Observable<Scene>;
  31299. /**
  31300. * An event triggered after animations processing
  31301. */
  31302. onAfterAnimationsObservable: Observable<Scene>;
  31303. /**
  31304. * An event triggered before draw calls are ready to be sent
  31305. */
  31306. onBeforeDrawPhaseObservable: Observable<Scene>;
  31307. /**
  31308. * An event triggered after draw calls have been sent
  31309. */
  31310. onAfterDrawPhaseObservable: Observable<Scene>;
  31311. /**
  31312. * An event triggered when the scene is ready
  31313. */
  31314. onReadyObservable: Observable<Scene>;
  31315. /**
  31316. * An event triggered before rendering a camera
  31317. */
  31318. onBeforeCameraRenderObservable: Observable<Camera>;
  31319. private _onBeforeCameraRenderObserver;
  31320. /** Sets a function to be executed before rendering a camera*/
  31321. beforeCameraRender: () => void;
  31322. /**
  31323. * An event triggered after rendering a camera
  31324. */
  31325. onAfterCameraRenderObservable: Observable<Camera>;
  31326. private _onAfterCameraRenderObserver;
  31327. /** Sets a function to be executed after rendering a camera*/
  31328. afterCameraRender: () => void;
  31329. /**
  31330. * An event triggered when active meshes evaluation is about to start
  31331. */
  31332. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31333. /**
  31334. * An event triggered when active meshes evaluation is done
  31335. */
  31336. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31337. /**
  31338. * An event triggered when particles rendering is about to start
  31339. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31340. */
  31341. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31342. /**
  31343. * An event triggered when particles rendering is done
  31344. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31345. */
  31346. onAfterParticlesRenderingObservable: Observable<Scene>;
  31347. /**
  31348. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31349. */
  31350. onDataLoadedObservable: Observable<Scene>;
  31351. /**
  31352. * An event triggered when a camera is created
  31353. */
  31354. onNewCameraAddedObservable: Observable<Camera>;
  31355. /**
  31356. * An event triggered when a camera is removed
  31357. */
  31358. onCameraRemovedObservable: Observable<Camera>;
  31359. /**
  31360. * An event triggered when a light is created
  31361. */
  31362. onNewLightAddedObservable: Observable<Light>;
  31363. /**
  31364. * An event triggered when a light is removed
  31365. */
  31366. onLightRemovedObservable: Observable<Light>;
  31367. /**
  31368. * An event triggered when a geometry is created
  31369. */
  31370. onNewGeometryAddedObservable: Observable<Geometry>;
  31371. /**
  31372. * An event triggered when a geometry is removed
  31373. */
  31374. onGeometryRemovedObservable: Observable<Geometry>;
  31375. /**
  31376. * An event triggered when a transform node is created
  31377. */
  31378. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31379. /**
  31380. * An event triggered when a transform node is removed
  31381. */
  31382. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31383. /**
  31384. * An event triggered when a mesh is created
  31385. */
  31386. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31387. /**
  31388. * An event triggered when a mesh is removed
  31389. */
  31390. onMeshRemovedObservable: Observable<AbstractMesh>;
  31391. /**
  31392. * An event triggered when a skeleton is created
  31393. */
  31394. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31395. /**
  31396. * An event triggered when a skeleton is removed
  31397. */
  31398. onSkeletonRemovedObservable: Observable<Skeleton>;
  31399. /**
  31400. * An event triggered when a material is created
  31401. */
  31402. onNewMaterialAddedObservable: Observable<Material>;
  31403. /**
  31404. * An event triggered when a material is removed
  31405. */
  31406. onMaterialRemovedObservable: Observable<Material>;
  31407. /**
  31408. * An event triggered when a texture is created
  31409. */
  31410. onNewTextureAddedObservable: Observable<BaseTexture>;
  31411. /**
  31412. * An event triggered when a texture is removed
  31413. */
  31414. onTextureRemovedObservable: Observable<BaseTexture>;
  31415. /**
  31416. * An event triggered when render targets are about to be rendered
  31417. * Can happen multiple times per frame.
  31418. */
  31419. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31420. /**
  31421. * An event triggered when render targets were rendered.
  31422. * Can happen multiple times per frame.
  31423. */
  31424. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31425. /**
  31426. * An event triggered before calculating deterministic simulation step
  31427. */
  31428. onBeforeStepObservable: Observable<Scene>;
  31429. /**
  31430. * An event triggered after calculating deterministic simulation step
  31431. */
  31432. onAfterStepObservable: Observable<Scene>;
  31433. /**
  31434. * An event triggered when the activeCamera property is updated
  31435. */
  31436. onActiveCameraChanged: Observable<Scene>;
  31437. /**
  31438. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31439. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31440. * 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)
  31441. */
  31442. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31443. /**
  31444. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31445. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31446. * 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)
  31447. */
  31448. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31449. /**
  31450. * This Observable will when a mesh has been imported into the scene.
  31451. */
  31452. onMeshImportedObservable: Observable<AbstractMesh>;
  31453. /**
  31454. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  31455. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  31456. */
  31457. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  31458. /** @hidden */ registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31459. /**
  31460. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31461. */
  31462. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31463. /**
  31464. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31465. */
  31466. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31467. /**
  31468. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31469. */
  31470. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31471. private _onPointerMove;
  31472. private _onPointerDown;
  31473. private _onPointerUp;
  31474. /** Callback called when a pointer move is detected */
  31475. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31476. /** Callback called when a pointer down is detected */
  31477. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31478. /** Callback called when a pointer up is detected */
  31479. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31480. /** Callback called when a pointer pick is detected */
  31481. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31482. /**
  31483. * 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).
  31484. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31485. */
  31486. onPrePointerObservable: Observable<PointerInfoPre>;
  31487. /**
  31488. * Observable event triggered each time an input event is received from the rendering canvas
  31489. */
  31490. onPointerObservable: Observable<PointerInfo>;
  31491. /**
  31492. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  31493. */
  31494. readonly unTranslatedPointer: Vector2;
  31495. /** The distance in pixel that you have to move to prevent some events */
  31496. static DragMovementThreshold: number;
  31497. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31498. static LongPressDelay: number;
  31499. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31500. static DoubleClickDelay: number;
  31501. /** If you need to check double click without raising a single click at first click, enable this flag */
  31502. static ExclusiveDoubleClickMode: boolean;
  31503. private _initClickEvent;
  31504. private _initActionManager;
  31505. private _delayedSimpleClick;
  31506. private _delayedSimpleClickTimeout;
  31507. private _previousDelayedSimpleClickTimeout;
  31508. private _meshPickProceed;
  31509. private _previousButtonPressed;
  31510. private _currentPickResult;
  31511. private _previousPickResult;
  31512. private _totalPointersPressed;
  31513. private _doubleClickOccured;
  31514. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31515. cameraToUseForPointers: Nullable<Camera>;
  31516. private _pointerX;
  31517. private _pointerY;
  31518. private _unTranslatedPointerX;
  31519. private _unTranslatedPointerY;
  31520. private _startingPointerPosition;
  31521. private _previousStartingPointerPosition;
  31522. private _startingPointerTime;
  31523. private _previousStartingPointerTime;
  31524. private _pointerCaptures;
  31525. private _timeAccumulator;
  31526. private _currentStepId;
  31527. private _currentInternalStep;
  31528. /** @hidden */ mirroredCameraPosition: Nullable<Vector3>;
  31529. /**
  31530. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  31531. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  31532. */
  31533. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  31534. /**
  31535. * Observable event triggered each time an keyboard event is received from the hosting window
  31536. */
  31537. onKeyboardObservable: Observable<KeyboardInfo>;
  31538. private _onKeyDown;
  31539. private _onKeyUp;
  31540. private _onCanvasFocusObserver;
  31541. private _onCanvasBlurObserver;
  31542. private _useRightHandedSystem;
  31543. /**
  31544. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  31545. */
  31546. useRightHandedSystem: boolean;
  31547. /**
  31548. * Sets the step Id used by deterministic lock step
  31549. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31550. * @param newStepId defines the step Id
  31551. */
  31552. setStepId(newStepId: number): void;
  31553. /**
  31554. * Gets the step Id used by deterministic lock step
  31555. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31556. * @returns the step Id
  31557. */
  31558. getStepId(): number;
  31559. /**
  31560. * Gets the internal step used by deterministic lock step
  31561. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31562. * @returns the internal step
  31563. */
  31564. getInternalStep(): number;
  31565. private _fogEnabled;
  31566. /**
  31567. * Gets or sets a boolean indicating if fog is enabled on this scene
  31568. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31569. * (Default is true)
  31570. */
  31571. fogEnabled: boolean;
  31572. private _fogMode;
  31573. /**
  31574. * Gets or sets the fog mode to use
  31575. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31576. * | mode | value |
  31577. * | --- | --- |
  31578. * | FOGMODE_NONE | 0 |
  31579. * | FOGMODE_EXP | 1 |
  31580. * | FOGMODE_EXP2 | 2 |
  31581. * | FOGMODE_LINEAR | 3 |
  31582. */
  31583. fogMode: number;
  31584. /**
  31585. * Gets or sets the fog color to use
  31586. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31587. * (Default is Color3(0.2, 0.2, 0.3))
  31588. */
  31589. fogColor: Color3;
  31590. /**
  31591. * Gets or sets the fog density to use
  31592. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31593. * (Default is 0.1)
  31594. */
  31595. fogDensity: number;
  31596. /**
  31597. * Gets or sets the fog start distance to use
  31598. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31599. * (Default is 0)
  31600. */
  31601. fogStart: number;
  31602. /**
  31603. * Gets or sets the fog end distance to use
  31604. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31605. * (Default is 1000)
  31606. */
  31607. fogEnd: number;
  31608. private _shadowsEnabled;
  31609. /**
  31610. * Gets or sets a boolean indicating if shadows are enabled on this scene
  31611. */
  31612. shadowsEnabled: boolean;
  31613. private _lightsEnabled;
  31614. /**
  31615. * Gets or sets a boolean indicating if lights are enabled on this scene
  31616. */
  31617. lightsEnabled: boolean;
  31618. /** All of the active cameras added to this scene. */
  31619. activeCameras: Camera[];
  31620. /** @hidden */ activeCamera: Nullable<Camera>;
  31621. /** Gets or sets the current active camera */
  31622. activeCamera: Nullable<Camera>;
  31623. private _defaultMaterial;
  31624. /** The default material used on meshes when no material is affected */
  31625. /** The default material used on meshes when no material is affected */
  31626. defaultMaterial: Material;
  31627. private _texturesEnabled;
  31628. /**
  31629. * Gets or sets a boolean indicating if textures are enabled on this scene
  31630. */
  31631. texturesEnabled: boolean;
  31632. /**
  31633. * Gets or sets a boolean indicating if particles are enabled on this scene
  31634. */
  31635. particlesEnabled: boolean;
  31636. /**
  31637. * Gets or sets a boolean indicating if sprites are enabled on this scene
  31638. */
  31639. spritesEnabled: boolean;
  31640. private _skeletonsEnabled;
  31641. /**
  31642. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  31643. */
  31644. skeletonsEnabled: boolean;
  31645. /**
  31646. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  31647. */
  31648. lensFlaresEnabled: boolean;
  31649. /**
  31650. * Gets or sets a boolean indicating if collisions are enabled on this scene
  31651. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31652. */
  31653. collisionsEnabled: boolean;
  31654. private _collisionCoordinator;
  31655. /** @hidden */
  31656. readonly collisionCoordinator: ICollisionCoordinator;
  31657. /**
  31658. * Defines the gravity applied to this scene (used only for collisions)
  31659. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31660. */
  31661. gravity: Vector3;
  31662. /**
  31663. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  31664. */
  31665. postProcessesEnabled: boolean;
  31666. /**
  31667. * The list of postprocesses added to the scene
  31668. */
  31669. postProcesses: PostProcess[];
  31670. /**
  31671. * Gets the current postprocess manager
  31672. */
  31673. postProcessManager: PostProcessManager;
  31674. /**
  31675. * Gets or sets a boolean indicating if render targets are enabled on this scene
  31676. */
  31677. renderTargetsEnabled: boolean;
  31678. /**
  31679. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  31680. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  31681. */
  31682. dumpNextRenderTargets: boolean;
  31683. /**
  31684. * The list of user defined render targets added to the scene
  31685. */
  31686. customRenderTargets: RenderTargetTexture[];
  31687. /**
  31688. * Defines if texture loading must be delayed
  31689. * If true, textures will only be loaded when they need to be rendered
  31690. */
  31691. useDelayedTextureLoading: boolean;
  31692. /**
  31693. * Gets the list of meshes imported to the scene through SceneLoader
  31694. */
  31695. importedMeshesFiles: String[];
  31696. /**
  31697. * Gets or sets a boolean indicating if probes are enabled on this scene
  31698. */
  31699. probesEnabled: boolean;
  31700. /**
  31701. * Gets or sets the current offline provider to use to store scene data
  31702. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  31703. */
  31704. offlineProvider: IOfflineProvider;
  31705. /**
  31706. * Gets or sets the action manager associated with the scene
  31707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31708. */
  31709. actionManager: AbstractActionManager;
  31710. private _meshesForIntersections;
  31711. /**
  31712. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  31713. */
  31714. proceduralTexturesEnabled: boolean;
  31715. private _engine;
  31716. private _totalVertices;
  31717. /** @hidden */ activeIndices: PerfCounter;
  31718. /** @hidden */ activeParticles: PerfCounter;
  31719. /** @hidden */ activeBones: PerfCounter;
  31720. private _animationRatio;
  31721. /** @hidden */ animationTimeLast: number;
  31722. /** @hidden */ animationTime: number;
  31723. /**
  31724. * Gets or sets a general scale for animation speed
  31725. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  31726. */
  31727. animationTimeScale: number;
  31728. /** @hidden */ cachedMaterial: Nullable<Material>;
  31729. /** @hidden */ cachedEffect: Nullable<Effect>;
  31730. /** @hidden */ cachedVisibility: Nullable<number>;
  31731. private _renderId;
  31732. private _frameId;
  31733. private _executeWhenReadyTimeoutId;
  31734. private _intermediateRendering;
  31735. private _viewUpdateFlag;
  31736. private _projectionUpdateFlag;
  31737. /** @hidden */ toBeDisposed: Nullable<IDisposable>[];
  31738. private _activeRequests;
  31739. /** @hidden */ pendingData: any[];
  31740. private _isDisposed;
  31741. /**
  31742. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  31743. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  31744. */
  31745. dispatchAllSubMeshesOfActiveMeshes: boolean;
  31746. private _activeMeshes;
  31747. private _processedMaterials;
  31748. private _renderTargets;
  31749. /** @hidden */ activeParticleSystems: SmartArray<IParticleSystem>;
  31750. private _activeSkeletons;
  31751. private _softwareSkinnedMeshes;
  31752. private _renderingManager;
  31753. /** @hidden */ activeAnimatables: Animatable[];
  31754. private _transformMatrix;
  31755. private _sceneUbo;
  31756. /** @hidden */ viewMatrix: Matrix;
  31757. private _projectionMatrix;
  31758. private _wheelEventName;
  31759. /** @hidden */ forcedViewPosition: Nullable<Vector3>;
  31760. /** @hidden */ frustumPlanes: Plane[];
  31761. /**
  31762. * Gets the list of frustum planes (built from the active camera)
  31763. */
  31764. readonly frustumPlanes: Plane[];
  31765. /**
  31766. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  31767. * This is useful if there are more lights that the maximum simulteanous authorized
  31768. */
  31769. requireLightSorting: boolean;
  31770. /** @hidden */
  31771. readonly useMaterialMeshMap: boolean;
  31772. /** @hidden */
  31773. readonly useClonedMeshhMap: boolean;
  31774. private _pointerOverMesh;
  31775. private _pickedDownMesh;
  31776. private _pickedUpMesh;
  31777. private _externalData;
  31778. private _uid;
  31779. /**
  31780. * @hidden
  31781. * Backing store of defined scene components.
  31782. */ components: ISceneComponent[];
  31783. /**
  31784. * @hidden
  31785. * Backing store of defined scene components.
  31786. */ serializableComponents: ISceneSerializableComponent[];
  31787. /**
  31788. * List of components to register on the next registration step.
  31789. */
  31790. private _transientComponents;
  31791. /**
  31792. * Registers the transient components if needed.
  31793. */
  31794. private _registerTransientComponents;
  31795. /**
  31796. * @hidden
  31797. * Add a component to the scene.
  31798. * Note that the ccomponent could be registered on th next frame if this is called after
  31799. * the register component stage.
  31800. * @param component Defines the component to add to the scene
  31801. */ addComponent(component: ISceneComponent): void;
  31802. /**
  31803. * @hidden
  31804. * Gets a component from the scene.
  31805. * @param name defines the name of the component to retrieve
  31806. * @returns the component or null if not present
  31807. */ getComponent(name: string): Nullable<ISceneComponent>;
  31808. /**
  31809. * @hidden
  31810. * Defines the actions happening before camera updates.
  31811. */ beforeCameraUpdateStage: Stage<SimpleStageAction>;
  31812. /**
  31813. * @hidden
  31814. * Defines the actions happening before clear the canvas.
  31815. */ beforeClearStage: Stage<SimpleStageAction>;
  31816. /**
  31817. * @hidden
  31818. * Defines the actions when collecting render targets for the frame.
  31819. */ gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31820. /**
  31821. * @hidden
  31822. * Defines the actions happening for one camera in the frame.
  31823. */ gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31824. /**
  31825. * @hidden
  31826. * Defines the actions happening during the per mesh ready checks.
  31827. */ isReadyForMeshStage: Stage<MeshStageAction>;
  31828. /**
  31829. * @hidden
  31830. * Defines the actions happening before evaluate active mesh checks.
  31831. */ beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  31832. /**
  31833. * @hidden
  31834. * Defines the actions happening during the evaluate sub mesh checks.
  31835. */ evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  31836. /**
  31837. * @hidden
  31838. * Defines the actions happening during the active mesh stage.
  31839. */ activeMeshStage: Stage<ActiveMeshStageAction>;
  31840. /**
  31841. * @hidden
  31842. * Defines the actions happening during the per camera render target step.
  31843. */ cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  31844. /**
  31845. * @hidden
  31846. * Defines the actions happening just before the active camera is drawing.
  31847. */ beforeCameraDrawStage: Stage<CameraStageAction>;
  31848. /**
  31849. * @hidden
  31850. * Defines the actions happening just before a render target is drawing.
  31851. */ beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31852. /**
  31853. * @hidden
  31854. * Defines the actions happening just before a rendering group is drawing.
  31855. */ beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31856. /**
  31857. * @hidden
  31858. * Defines the actions happening just before a mesh is drawing.
  31859. */ beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31860. /**
  31861. * @hidden
  31862. * Defines the actions happening just after a mesh has been drawn.
  31863. */ afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31864. /**
  31865. * @hidden
  31866. * Defines the actions happening just after a rendering group has been drawn.
  31867. */ afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31868. /**
  31869. * @hidden
  31870. * Defines the actions happening just after the active camera has been drawn.
  31871. */ afterCameraDrawStage: Stage<CameraStageAction>;
  31872. /**
  31873. * @hidden
  31874. * Defines the actions happening just after a render target has been drawn.
  31875. */ afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31876. /**
  31877. * @hidden
  31878. * Defines the actions happening just after rendering all cameras and computing intersections.
  31879. */ afterRenderStage: Stage<SimpleStageAction>;
  31880. /**
  31881. * @hidden
  31882. * Defines the actions happening when a pointer move event happens.
  31883. */ pointerMoveStage: Stage<PointerMoveStageAction>;
  31884. /**
  31885. * @hidden
  31886. * Defines the actions happening when a pointer down event happens.
  31887. */ pointerDownStage: Stage<PointerUpDownStageAction>;
  31888. /**
  31889. * @hidden
  31890. * Defines the actions happening when a pointer up event happens.
  31891. */ pointerUpStage: Stage<PointerUpDownStageAction>;
  31892. /**
  31893. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  31894. */
  31895. private geometriesByUniqueId;
  31896. /**
  31897. * Creates a new Scene
  31898. * @param engine defines the engine to use to render this scene
  31899. * @param options defines the scene options
  31900. */
  31901. constructor(engine: Engine, options?: SceneOptions);
  31902. /**
  31903. * Gets a string idenfifying the name of the class
  31904. * @returns "Scene" string
  31905. */
  31906. getClassName(): string;
  31907. private _defaultMeshCandidates;
  31908. /**
  31909. * @hidden
  31910. */ getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  31911. private _defaultSubMeshCandidates;
  31912. /**
  31913. * @hidden
  31914. */ getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  31915. /**
  31916. * Sets the default candidate providers for the scene.
  31917. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  31918. * and getCollidingSubMeshCandidates to their default function
  31919. */
  31920. setDefaultCandidateProviders(): void;
  31921. /**
  31922. * Gets the mesh that is currently under the pointer
  31923. */
  31924. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31925. /**
  31926. * Gets or sets the current on-screen X position of the pointer
  31927. */
  31928. pointerX: number;
  31929. /**
  31930. * Gets or sets the current on-screen Y position of the pointer
  31931. */
  31932. pointerY: number;
  31933. /**
  31934. * Gets the cached material (ie. the latest rendered one)
  31935. * @returns the cached material
  31936. */
  31937. getCachedMaterial(): Nullable<Material>;
  31938. /**
  31939. * Gets the cached effect (ie. the latest rendered one)
  31940. * @returns the cached effect
  31941. */
  31942. getCachedEffect(): Nullable<Effect>;
  31943. /**
  31944. * Gets the cached visibility state (ie. the latest rendered one)
  31945. * @returns the cached visibility state
  31946. */
  31947. getCachedVisibility(): Nullable<number>;
  31948. /**
  31949. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  31950. * @param material defines the current material
  31951. * @param effect defines the current effect
  31952. * @param visibility defines the current visibility state
  31953. * @returns true if one parameter is not cached
  31954. */
  31955. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  31956. /**
  31957. * Gets the engine associated with the scene
  31958. * @returns an Engine
  31959. */
  31960. getEngine(): Engine;
  31961. /**
  31962. * Gets the total number of vertices rendered per frame
  31963. * @returns the total number of vertices rendered per frame
  31964. */
  31965. getTotalVertices(): number;
  31966. /**
  31967. * Gets the performance counter for total vertices
  31968. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31969. */
  31970. readonly totalVerticesPerfCounter: PerfCounter;
  31971. /**
  31972. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  31973. * @returns the total number of active indices rendered per frame
  31974. */
  31975. getActiveIndices(): number;
  31976. /**
  31977. * Gets the performance counter for active indices
  31978. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31979. */
  31980. readonly totalActiveIndicesPerfCounter: PerfCounter;
  31981. /**
  31982. * Gets the total number of active particles rendered per frame
  31983. * @returns the total number of active particles rendered per frame
  31984. */
  31985. getActiveParticles(): number;
  31986. /**
  31987. * Gets the performance counter for active particles
  31988. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31989. */
  31990. readonly activeParticlesPerfCounter: PerfCounter;
  31991. /**
  31992. * Gets the total number of active bones rendered per frame
  31993. * @returns the total number of active bones rendered per frame
  31994. */
  31995. getActiveBones(): number;
  31996. /**
  31997. * Gets the performance counter for active bones
  31998. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31999. */
  32000. readonly activeBonesPerfCounter: PerfCounter;
  32001. /**
  32002. * Gets the array of active meshes
  32003. * @returns an array of AbstractMesh
  32004. */
  32005. getActiveMeshes(): SmartArray<AbstractMesh>;
  32006. /**
  32007. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32008. * @returns a number
  32009. */
  32010. getAnimationRatio(): number;
  32011. /**
  32012. * Gets an unique Id for the current render phase
  32013. * @returns a number
  32014. */
  32015. getRenderId(): number;
  32016. /**
  32017. * Gets an unique Id for the current frame
  32018. * @returns a number
  32019. */
  32020. getFrameId(): number;
  32021. /** Call this function if you want to manually increment the render Id*/
  32022. incrementRenderId(): void;
  32023. private _updatePointerPosition;
  32024. private _createUbo;
  32025. private _setRayOnPointerInfo;
  32026. /**
  32027. * Use this method to simulate a pointer move on a mesh
  32028. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32029. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32030. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32031. * @returns the current scene
  32032. */
  32033. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32034. private _processPointerMove;
  32035. private _checkPrePointerObservable;
  32036. /**
  32037. * Use this method to simulate a pointer down on a mesh
  32038. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32039. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32040. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32041. * @returns the current scene
  32042. */
  32043. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32044. private _processPointerDown;
  32045. /**
  32046. * Use this method to simulate a pointer up on a mesh
  32047. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32048. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32049. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32050. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32051. * @returns the current scene
  32052. */
  32053. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32054. private _processPointerUp;
  32055. /**
  32056. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32057. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32058. * @returns true if the pointer was captured
  32059. */
  32060. isPointerCaptured(pointerId?: number): boolean;
  32061. /** @hidden */ isPointerSwiping(): boolean;
  32062. /**
  32063. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32064. * @param attachUp defines if you want to attach events to pointerup
  32065. * @param attachDown defines if you want to attach events to pointerdown
  32066. * @param attachMove defines if you want to attach events to pointermove
  32067. */
  32068. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32069. /** Detaches all event handlers*/
  32070. detachControl(): void;
  32071. /**
  32072. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32073. * Delay loaded resources are not taking in account
  32074. * @return true if all required resources are ready
  32075. */
  32076. isReady(): boolean;
  32077. /** Resets all cached information relative to material (including effect and visibility) */
  32078. resetCachedMaterial(): void;
  32079. /**
  32080. * Registers a function to be called before every frame render
  32081. * @param func defines the function to register
  32082. */
  32083. registerBeforeRender(func: () => void): void;
  32084. /**
  32085. * Unregisters a function called before every frame render
  32086. * @param func defines the function to unregister
  32087. */
  32088. unregisterBeforeRender(func: () => void): void;
  32089. /**
  32090. * Registers a function to be called after every frame render
  32091. * @param func defines the function to register
  32092. */
  32093. registerAfterRender(func: () => void): void;
  32094. /**
  32095. * Unregisters a function called after every frame render
  32096. * @param func defines the function to unregister
  32097. */
  32098. unregisterAfterRender(func: () => void): void;
  32099. private _executeOnceBeforeRender;
  32100. /**
  32101. * The provided function will run before render once and will be disposed afterwards.
  32102. * A timeout delay can be provided so that the function will be executed in N ms.
  32103. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32104. * @param func The function to be executed.
  32105. * @param timeout optional delay in ms
  32106. */
  32107. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32108. /** @hidden */ addPendingData(data: any): void;
  32109. /** @hidden */ removePendingData(data: any): void;
  32110. /**
  32111. * Returns the number of items waiting to be loaded
  32112. * @returns the number of items waiting to be loaded
  32113. */
  32114. getWaitingItemsCount(): number;
  32115. /**
  32116. * Returns a boolean indicating if the scene is still loading data
  32117. */
  32118. readonly isLoading: boolean;
  32119. /**
  32120. * Registers a function to be executed when the scene is ready
  32121. * @param {Function} func - the function to be executed
  32122. */
  32123. executeWhenReady(func: () => void): void;
  32124. /**
  32125. * Returns a promise that resolves when the scene is ready
  32126. * @returns A promise that resolves when the scene is ready
  32127. */
  32128. whenReadyAsync(): Promise<void>;
  32129. /** @hidden */ checkIsReady(): void;
  32130. /**
  32131. * Gets all animatable attached to the scene
  32132. */
  32133. readonly animatables: Animatable[];
  32134. /**
  32135. * Resets the last animation time frame.
  32136. * Useful to override when animations start running when loading a scene for the first time.
  32137. */
  32138. resetLastAnimationTimeFrame(): void;
  32139. /**
  32140. * Gets the current view matrix
  32141. * @returns a Matrix
  32142. */
  32143. getViewMatrix(): Matrix;
  32144. /**
  32145. * Gets the current projection matrix
  32146. * @returns a Matrix
  32147. */
  32148. getProjectionMatrix(): Matrix;
  32149. /**
  32150. * Gets the current transform matrix
  32151. * @returns a Matrix made of View * Projection
  32152. */
  32153. getTransformMatrix(): Matrix;
  32154. /**
  32155. * Sets the current transform matrix
  32156. * @param viewL defines the View matrix to use
  32157. * @param projectionL defines the Projection matrix to use
  32158. * @param viewR defines the right View matrix to use (if provided)
  32159. * @param projectionR defines the right Projection matrix to use (if provided)
  32160. */
  32161. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32162. /**
  32163. * Gets the uniform buffer used to store scene data
  32164. * @returns a UniformBuffer
  32165. */
  32166. getSceneUniformBuffer(): UniformBuffer;
  32167. /**
  32168. * Gets an unique (relatively to the current scene) Id
  32169. * @returns an unique number for the scene
  32170. */
  32171. getUniqueId(): number;
  32172. /**
  32173. * Add a mesh to the list of scene's meshes
  32174. * @param newMesh defines the mesh to add
  32175. * @param recursive if all child meshes should also be added to the scene
  32176. */
  32177. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32178. /**
  32179. * Remove a mesh for the list of scene's meshes
  32180. * @param toRemove defines the mesh to remove
  32181. * @param recursive if all child meshes should also be removed from the scene
  32182. * @returns the index where the mesh was in the mesh list
  32183. */
  32184. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32185. /**
  32186. * Add a transform node to the list of scene's transform nodes
  32187. * @param newTransformNode defines the transform node to add
  32188. */
  32189. addTransformNode(newTransformNode: TransformNode): void;
  32190. /**
  32191. * Remove a transform node for the list of scene's transform nodes
  32192. * @param toRemove defines the transform node to remove
  32193. * @returns the index where the transform node was in the transform node list
  32194. */
  32195. removeTransformNode(toRemove: TransformNode): number;
  32196. /**
  32197. * Remove a skeleton for the list of scene's skeletons
  32198. * @param toRemove defines the skeleton to remove
  32199. * @returns the index where the skeleton was in the skeleton list
  32200. */
  32201. removeSkeleton(toRemove: Skeleton): number;
  32202. /**
  32203. * Remove a morph target for the list of scene's morph targets
  32204. * @param toRemove defines the morph target to remove
  32205. * @returns the index where the morph target was in the morph target list
  32206. */
  32207. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32208. /**
  32209. * Remove a light for the list of scene's lights
  32210. * @param toRemove defines the light to remove
  32211. * @returns the index where the light was in the light list
  32212. */
  32213. removeLight(toRemove: Light): number;
  32214. /**
  32215. * Remove a camera for the list of scene's cameras
  32216. * @param toRemove defines the camera to remove
  32217. * @returns the index where the camera was in the camera list
  32218. */
  32219. removeCamera(toRemove: Camera): number;
  32220. /**
  32221. * Remove a particle system for the list of scene's particle systems
  32222. * @param toRemove defines the particle system to remove
  32223. * @returns the index where the particle system was in the particle system list
  32224. */
  32225. removeParticleSystem(toRemove: IParticleSystem): number;
  32226. /**
  32227. * Remove a animation for the list of scene's animations
  32228. * @param toRemove defines the animation to remove
  32229. * @returns the index where the animation was in the animation list
  32230. */
  32231. removeAnimation(toRemove: Animation): number;
  32232. /**
  32233. * Removes the given animation group from this scene.
  32234. * @param toRemove The animation group to remove
  32235. * @returns The index of the removed animation group
  32236. */
  32237. removeAnimationGroup(toRemove: AnimationGroup): number;
  32238. /**
  32239. * Removes the given multi-material from this scene.
  32240. * @param toRemove The multi-material to remove
  32241. * @returns The index of the removed multi-material
  32242. */
  32243. removeMultiMaterial(toRemove: MultiMaterial): number;
  32244. /**
  32245. * Removes the given material from this scene.
  32246. * @param toRemove The material to remove
  32247. * @returns The index of the removed material
  32248. */
  32249. removeMaterial(toRemove: Material): number;
  32250. /**
  32251. * Removes the given action manager from this scene.
  32252. * @param toRemove The action manager to remove
  32253. * @returns The index of the removed action manager
  32254. */
  32255. removeActionManager(toRemove: AbstractActionManager): number;
  32256. /**
  32257. * Removes the given texture from this scene.
  32258. * @param toRemove The texture to remove
  32259. * @returns The index of the removed texture
  32260. */
  32261. removeTexture(toRemove: BaseTexture): number;
  32262. /**
  32263. * Adds the given light to this scene
  32264. * @param newLight The light to add
  32265. */
  32266. addLight(newLight: Light): void;
  32267. /**
  32268. * Sorts the list list based on light priorities
  32269. */
  32270. sortLightsByPriority(): void;
  32271. /**
  32272. * Adds the given camera to this scene
  32273. * @param newCamera The camera to add
  32274. */
  32275. addCamera(newCamera: Camera): void;
  32276. /**
  32277. * Adds the given skeleton to this scene
  32278. * @param newSkeleton The skeleton to add
  32279. */
  32280. addSkeleton(newSkeleton: Skeleton): void;
  32281. /**
  32282. * Adds the given particle system to this scene
  32283. * @param newParticleSystem The particle system to add
  32284. */
  32285. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32286. /**
  32287. * Adds the given animation to this scene
  32288. * @param newAnimation The animation to add
  32289. */
  32290. addAnimation(newAnimation: Animation): void;
  32291. /**
  32292. * Adds the given animation group to this scene.
  32293. * @param newAnimationGroup The animation group to add
  32294. */
  32295. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32296. /**
  32297. * Adds the given multi-material to this scene
  32298. * @param newMultiMaterial The multi-material to add
  32299. */
  32300. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32301. /**
  32302. * Adds the given material to this scene
  32303. * @param newMaterial The material to add
  32304. */
  32305. addMaterial(newMaterial: Material): void;
  32306. /**
  32307. * Adds the given morph target to this scene
  32308. * @param newMorphTargetManager The morph target to add
  32309. */
  32310. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32311. /**
  32312. * Adds the given geometry to this scene
  32313. * @param newGeometry The geometry to add
  32314. */
  32315. addGeometry(newGeometry: Geometry): void;
  32316. /**
  32317. * Adds the given action manager to this scene
  32318. * @param newActionManager The action manager to add
  32319. */
  32320. addActionManager(newActionManager: AbstractActionManager): void;
  32321. /**
  32322. * Adds the given texture to this scene.
  32323. * @param newTexture The texture to add
  32324. */
  32325. addTexture(newTexture: BaseTexture): void;
  32326. /**
  32327. * Switch active camera
  32328. * @param newCamera defines the new active camera
  32329. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32330. */
  32331. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32332. /**
  32333. * sets the active camera of the scene using its ID
  32334. * @param id defines the camera's ID
  32335. * @return the new active camera or null if none found.
  32336. */
  32337. setActiveCameraByID(id: string): Nullable<Camera>;
  32338. /**
  32339. * sets the active camera of the scene using its name
  32340. * @param name defines the camera's name
  32341. * @returns the new active camera or null if none found.
  32342. */
  32343. setActiveCameraByName(name: string): Nullable<Camera>;
  32344. /**
  32345. * get an animation group using its name
  32346. * @param name defines the material's name
  32347. * @return the animation group or null if none found.
  32348. */
  32349. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32350. /**
  32351. * Get a material using its unique id
  32352. * @param uniqueId defines the material's unique id
  32353. * @return the material or null if none found.
  32354. */
  32355. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  32356. /**
  32357. * get a material using its id
  32358. * @param id defines the material's ID
  32359. * @return the material or null if none found.
  32360. */
  32361. getMaterialByID(id: string): Nullable<Material>;
  32362. /**
  32363. * Gets a material using its name
  32364. * @param name defines the material's name
  32365. * @return the material or null if none found.
  32366. */
  32367. getMaterialByName(name: string): Nullable<Material>;
  32368. /**
  32369. * Gets a camera using its id
  32370. * @param id defines the id to look for
  32371. * @returns the camera or null if not found
  32372. */
  32373. getCameraByID(id: string): Nullable<Camera>;
  32374. /**
  32375. * Gets a camera using its unique id
  32376. * @param uniqueId defines the unique id to look for
  32377. * @returns the camera or null if not found
  32378. */
  32379. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32380. /**
  32381. * Gets a camera using its name
  32382. * @param name defines the camera's name
  32383. * @return the camera or null if none found.
  32384. */
  32385. getCameraByName(name: string): Nullable<Camera>;
  32386. /**
  32387. * Gets a bone using its id
  32388. * @param id defines the bone's id
  32389. * @return the bone or null if not found
  32390. */
  32391. getBoneByID(id: string): Nullable<Bone>;
  32392. /**
  32393. * Gets a bone using its id
  32394. * @param name defines the bone's name
  32395. * @return the bone or null if not found
  32396. */
  32397. getBoneByName(name: string): Nullable<Bone>;
  32398. /**
  32399. * Gets a light node using its name
  32400. * @param name defines the the light's name
  32401. * @return the light or null if none found.
  32402. */
  32403. getLightByName(name: string): Nullable<Light>;
  32404. /**
  32405. * Gets a light node using its id
  32406. * @param id defines the light's id
  32407. * @return the light or null if none found.
  32408. */
  32409. getLightByID(id: string): Nullable<Light>;
  32410. /**
  32411. * Gets a light node using its scene-generated unique ID
  32412. * @param uniqueId defines the light's unique id
  32413. * @return the light or null if none found.
  32414. */
  32415. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32416. /**
  32417. * Gets a particle system by id
  32418. * @param id defines the particle system id
  32419. * @return the corresponding system or null if none found
  32420. */
  32421. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32422. /**
  32423. * Gets a geometry using its ID
  32424. * @param id defines the geometry's id
  32425. * @return the geometry or null if none found.
  32426. */
  32427. getGeometryByID(id: string): Nullable<Geometry>;
  32428. private _getGeometryByUniqueID;
  32429. /**
  32430. * Add a new geometry to this scene
  32431. * @param geometry defines the geometry to be added to the scene.
  32432. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32433. * @return a boolean defining if the geometry was added or not
  32434. */
  32435. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32436. /**
  32437. * Removes an existing geometry
  32438. * @param geometry defines the geometry to be removed from the scene
  32439. * @return a boolean defining if the geometry was removed or not
  32440. */
  32441. removeGeometry(geometry: Geometry): boolean;
  32442. /**
  32443. * Gets the list of geometries attached to the scene
  32444. * @returns an array of Geometry
  32445. */
  32446. getGeometries(): Geometry[];
  32447. /**
  32448. * Gets the first added mesh found of a given ID
  32449. * @param id defines the id to search for
  32450. * @return the mesh found or null if not found at all
  32451. */
  32452. getMeshByID(id: string): Nullable<AbstractMesh>;
  32453. /**
  32454. * Gets a list of meshes using their id
  32455. * @param id defines the id to search for
  32456. * @returns a list of meshes
  32457. */
  32458. getMeshesByID(id: string): Array<AbstractMesh>;
  32459. /**
  32460. * Gets the first added transform node found of a given ID
  32461. * @param id defines the id to search for
  32462. * @return the found transform node or null if not found at all.
  32463. */
  32464. getTransformNodeByID(id: string): Nullable<TransformNode>;
  32465. /**
  32466. * Gets a transform node with its auto-generated unique id
  32467. * @param uniqueId efines the unique id to search for
  32468. * @return the found transform node or null if not found at all.
  32469. */
  32470. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  32471. /**
  32472. * Gets a list of transform nodes using their id
  32473. * @param id defines the id to search for
  32474. * @returns a list of transform nodes
  32475. */
  32476. getTransformNodesByID(id: string): Array<TransformNode>;
  32477. /**
  32478. * Gets a mesh with its auto-generated unique id
  32479. * @param uniqueId defines the unique id to search for
  32480. * @return the found mesh or null if not found at all.
  32481. */
  32482. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  32483. /**
  32484. * Gets a the last added mesh using a given id
  32485. * @param id defines the id to search for
  32486. * @return the found mesh or null if not found at all.
  32487. */
  32488. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  32489. /**
  32490. * Gets a the last added node (Mesh, Camera, Light) using a given id
  32491. * @param id defines the id to search for
  32492. * @return the found node or null if not found at all
  32493. */
  32494. getLastEntryByID(id: string): Nullable<Node>;
  32495. /**
  32496. * Gets a node (Mesh, Camera, Light) using a given id
  32497. * @param id defines the id to search for
  32498. * @return the found node or null if not found at all
  32499. */
  32500. getNodeByID(id: string): Nullable<Node>;
  32501. /**
  32502. * Gets a node (Mesh, Camera, Light) using a given name
  32503. * @param name defines the name to search for
  32504. * @return the found node or null if not found at all.
  32505. */
  32506. getNodeByName(name: string): Nullable<Node>;
  32507. /**
  32508. * Gets a mesh using a given name
  32509. * @param name defines the name to search for
  32510. * @return the found mesh or null if not found at all.
  32511. */
  32512. getMeshByName(name: string): Nullable<AbstractMesh>;
  32513. /**
  32514. * Gets a transform node using a given name
  32515. * @param name defines the name to search for
  32516. * @return the found transform node or null if not found at all.
  32517. */
  32518. getTransformNodeByName(name: string): Nullable<TransformNode>;
  32519. /**
  32520. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  32521. * @param id defines the id to search for
  32522. * @return the found skeleton or null if not found at all.
  32523. */
  32524. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  32525. /**
  32526. * Gets a skeleton using a given auto generated unique id
  32527. * @param uniqueId defines the unique id to search for
  32528. * @return the found skeleton or null if not found at all.
  32529. */
  32530. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  32531. /**
  32532. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  32533. * @param id defines the id to search for
  32534. * @return the found skeleton or null if not found at all.
  32535. */
  32536. getSkeletonById(id: string): Nullable<Skeleton>;
  32537. /**
  32538. * Gets a skeleton using a given name
  32539. * @param name defines the name to search for
  32540. * @return the found skeleton or null if not found at all.
  32541. */
  32542. getSkeletonByName(name: string): Nullable<Skeleton>;
  32543. /**
  32544. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  32545. * @param id defines the id to search for
  32546. * @return the found morph target manager or null if not found at all.
  32547. */
  32548. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  32549. /**
  32550. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  32551. * @param id defines the id to search for
  32552. * @return the found morph target or null if not found at all.
  32553. */
  32554. getMorphTargetById(id: string): Nullable<MorphTarget>;
  32555. /**
  32556. * Gets a boolean indicating if the given mesh is active
  32557. * @param mesh defines the mesh to look for
  32558. * @returns true if the mesh is in the active list
  32559. */
  32560. isActiveMesh(mesh: AbstractMesh): boolean;
  32561. /**
  32562. * Return a unique id as a string which can serve as an identifier for the scene
  32563. */
  32564. readonly uid: string;
  32565. /**
  32566. * Add an externaly attached data from its key.
  32567. * This method call will fail and return false, if such key already exists.
  32568. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32569. * @param key the unique key that identifies the data
  32570. * @param data the data object to associate to the key for this Engine instance
  32571. * @return true if no such key were already present and the data was added successfully, false otherwise
  32572. */
  32573. addExternalData<T>(key: string, data: T): boolean;
  32574. /**
  32575. * Get an externaly attached data from its key
  32576. * @param key the unique key that identifies the data
  32577. * @return the associated data, if present (can be null), or undefined if not present
  32578. */
  32579. getExternalData<T>(key: string): Nullable<T>;
  32580. /**
  32581. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32582. * @param key the unique key that identifies the data
  32583. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32584. * @return the associated data, can be null if the factory returned null.
  32585. */
  32586. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32587. /**
  32588. * Remove an externaly attached data from the Engine instance
  32589. * @param key the unique key that identifies the data
  32590. * @return true if the data was successfully removed, false if it doesn't exist
  32591. */
  32592. removeExternalData(key: string): boolean;
  32593. private _evaluateSubMesh;
  32594. /**
  32595. * Clear the processed materials smart array preventing retention point in material dispose.
  32596. */
  32597. freeProcessedMaterials(): void;
  32598. private _preventFreeActiveMeshesAndRenderingGroups;
  32599. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  32600. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  32601. * when disposing several meshes in a row or a hierarchy of meshes.
  32602. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  32603. */
  32604. blockfreeActiveMeshesAndRenderingGroups: boolean;
  32605. /**
  32606. * Clear the active meshes smart array preventing retention point in mesh dispose.
  32607. */
  32608. freeActiveMeshes(): void;
  32609. /**
  32610. * Clear the info related to rendering groups preventing retention points during dispose.
  32611. */
  32612. freeRenderingGroups(): void;
  32613. /** @hidden */ isInIntermediateRendering(): boolean;
  32614. /**
  32615. * Lambda returning the list of potentially active meshes.
  32616. */
  32617. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  32618. /**
  32619. * Lambda returning the list of potentially active sub meshes.
  32620. */
  32621. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  32622. /**
  32623. * Lambda returning the list of potentially intersecting sub meshes.
  32624. */
  32625. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  32626. /**
  32627. * Lambda returning the list of potentially colliding sub meshes.
  32628. */
  32629. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  32630. private _activeMeshesFrozen;
  32631. /**
  32632. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  32633. * @returns the current scene
  32634. */
  32635. freezeActiveMeshes(): Scene;
  32636. /**
  32637. * Use this function to restart evaluating active meshes on every frame
  32638. * @returns the current scene
  32639. */
  32640. unfreezeActiveMeshes(): Scene;
  32641. private _evaluateActiveMeshes;
  32642. private _activeMesh;
  32643. /**
  32644. * Update the transform matrix to update from the current active camera
  32645. * @param force defines a boolean used to force the update even if cache is up to date
  32646. */
  32647. updateTransformMatrix(force?: boolean): void;
  32648. private _bindFrameBuffer;
  32649. /** @hidden */ allowPostProcessClearColor: boolean;
  32650. /** @hidden */ renderForCamera(camera: Camera, rigParent?: Camera): void;
  32651. private _processSubCameras;
  32652. private _checkIntersections;
  32653. /** @hidden */ advancePhysicsEngineStep(step: number): void;
  32654. /**
  32655. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  32656. */
  32657. getDeterministicFrameTime: () => number;
  32658. /** @hidden */ animate(): void;
  32659. /**
  32660. * Render the scene
  32661. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  32662. */
  32663. render(updateCameras?: boolean): void;
  32664. /**
  32665. * Freeze all materials
  32666. * A frozen material will not be updatable but should be faster to render
  32667. */
  32668. freezeMaterials(): void;
  32669. /**
  32670. * Unfreeze all materials
  32671. * A frozen material will not be updatable but should be faster to render
  32672. */
  32673. unfreezeMaterials(): void;
  32674. /**
  32675. * Releases all held ressources
  32676. */
  32677. dispose(): void;
  32678. /**
  32679. * Gets if the scene is already disposed
  32680. */
  32681. readonly isDisposed: boolean;
  32682. /**
  32683. * Call this function to reduce memory footprint of the scene.
  32684. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  32685. */
  32686. clearCachedVertexData(): void;
  32687. /**
  32688. * This function will remove the local cached buffer data from texture.
  32689. * It will save memory but will prevent the texture from being rebuilt
  32690. */
  32691. cleanCachedTextureBuffer(): void;
  32692. /**
  32693. * Get the world extend vectors with an optional filter
  32694. *
  32695. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  32696. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  32697. */
  32698. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  32699. min: Vector3;
  32700. max: Vector3;
  32701. };
  32702. /**
  32703. * Creates a ray that can be used to pick in the scene
  32704. * @param x defines the x coordinate of the origin (on-screen)
  32705. * @param y defines the y coordinate of the origin (on-screen)
  32706. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32707. * @param camera defines the camera to use for the picking
  32708. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32709. * @returns a Ray
  32710. */
  32711. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  32712. /**
  32713. * Creates a ray that can be used to pick in the scene
  32714. * @param x defines the x coordinate of the origin (on-screen)
  32715. * @param y defines the y coordinate of the origin (on-screen)
  32716. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32717. * @param result defines the ray where to store the picking ray
  32718. * @param camera defines the camera to use for the picking
  32719. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32720. * @returns the current scene
  32721. */
  32722. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  32723. /**
  32724. * Creates a ray that can be used to pick in the scene
  32725. * @param x defines the x coordinate of the origin (on-screen)
  32726. * @param y defines the y coordinate of the origin (on-screen)
  32727. * @param camera defines the camera to use for the picking
  32728. * @returns a Ray
  32729. */
  32730. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  32731. /**
  32732. * Creates a ray that can be used to pick in the scene
  32733. * @param x defines the x coordinate of the origin (on-screen)
  32734. * @param y defines the y coordinate of the origin (on-screen)
  32735. * @param result defines the ray where to store the picking ray
  32736. * @param camera defines the camera to use for the picking
  32737. * @returns the current scene
  32738. */
  32739. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  32740. /** Launch a ray to try to pick a mesh in the scene
  32741. * @param x position on screen
  32742. * @param y position on screen
  32743. * @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
  32744. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  32745. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32746. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32747. * @returns a PickingInfo
  32748. */
  32749. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  32750. /** Use the given ray to pick a mesh in the scene
  32751. * @param ray The ray to use to pick meshes
  32752. * @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
  32753. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  32754. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32755. * @returns a PickingInfo
  32756. */
  32757. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  32758. /**
  32759. * Launch a ray to try to pick a mesh in the scene
  32760. * @param x X position on screen
  32761. * @param y Y position on screen
  32762. * @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
  32763. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32764. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32765. * @returns an array of PickingInfo
  32766. */
  32767. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32768. /**
  32769. * Launch a ray to try to pick a mesh in the scene
  32770. * @param ray Ray to use
  32771. * @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
  32772. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32773. * @returns an array of PickingInfo
  32774. */
  32775. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32776. /**
  32777. * Force the value of meshUnderPointer
  32778. * @param mesh defines the mesh to use
  32779. */
  32780. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32781. /**
  32782. * Gets the mesh under the pointer
  32783. * @returns a Mesh or null if no mesh is under the pointer
  32784. */
  32785. getPointerOverMesh(): Nullable<AbstractMesh>;
  32786. /** @hidden */ rebuildGeometries(): void;
  32787. /** @hidden */ rebuildTextures(): void;
  32788. private _getByTags;
  32789. /**
  32790. * Get a list of meshes by tags
  32791. * @param tagsQuery defines the tags query to use
  32792. * @param forEach defines a predicate used to filter results
  32793. * @returns an array of Mesh
  32794. */
  32795. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  32796. /**
  32797. * Get a list of cameras by tags
  32798. * @param tagsQuery defines the tags query to use
  32799. * @param forEach defines a predicate used to filter results
  32800. * @returns an array of Camera
  32801. */
  32802. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  32803. /**
  32804. * Get a list of lights by tags
  32805. * @param tagsQuery defines the tags query to use
  32806. * @param forEach defines a predicate used to filter results
  32807. * @returns an array of Light
  32808. */
  32809. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  32810. /**
  32811. * Get a list of materials by tags
  32812. * @param tagsQuery defines the tags query to use
  32813. * @param forEach defines a predicate used to filter results
  32814. * @returns an array of Material
  32815. */
  32816. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  32817. /**
  32818. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  32819. * This allowed control for front to back rendering or reversly depending of the special needs.
  32820. *
  32821. * @param renderingGroupId The rendering group id corresponding to its index
  32822. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  32823. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  32824. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  32825. */
  32826. 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;
  32827. /**
  32828. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  32829. *
  32830. * @param renderingGroupId The rendering group id corresponding to its index
  32831. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  32832. * @param depth Automatically clears depth between groups if true and autoClear is true.
  32833. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  32834. */
  32835. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  32836. /**
  32837. * Gets the current auto clear configuration for one rendering group of the rendering
  32838. * manager.
  32839. * @param index the rendering group index to get the information for
  32840. * @returns The auto clear setup for the requested rendering group
  32841. */
  32842. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  32843. private _blockMaterialDirtyMechanism;
  32844. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  32845. blockMaterialDirtyMechanism: boolean;
  32846. /**
  32847. * Will flag all materials as dirty to trigger new shader compilation
  32848. * @param flag defines the flag used to specify which material part must be marked as dirty
  32849. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  32850. */
  32851. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32852. /** @hidden */ loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  32853. /** @hidden */ loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32854. }
  32855. }
  32856. declare module BABYLON {
  32857. /**
  32858. * Set of assets to keep when moving a scene into an asset container.
  32859. */
  32860. export class KeepAssets extends AbstractScene {
  32861. }
  32862. /**
  32863. * Container with a set of assets that can be added or removed from a scene.
  32864. */
  32865. export class AssetContainer extends AbstractScene {
  32866. /**
  32867. * The scene the AssetContainer belongs to.
  32868. */
  32869. scene: Scene;
  32870. /**
  32871. * Instantiates an AssetContainer.
  32872. * @param scene The scene the AssetContainer belongs to.
  32873. */
  32874. constructor(scene: Scene);
  32875. /**
  32876. * Adds all the assets from the container to the scene.
  32877. */
  32878. addAllToScene(): void;
  32879. /**
  32880. * Removes all the assets in the container from the scene
  32881. */
  32882. removeAllFromScene(): void;
  32883. /**
  32884. * Disposes all the assets in the container
  32885. */
  32886. dispose(): void;
  32887. private _moveAssets;
  32888. /**
  32889. * Removes all the assets contained in the scene and adds them to the container.
  32890. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  32891. */
  32892. moveAllFromScene(keepAssets?: KeepAssets): void;
  32893. /**
  32894. * 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.
  32895. * @returns the root mesh
  32896. */
  32897. createRootMesh(): Mesh;
  32898. }
  32899. }
  32900. declare module BABYLON {
  32901. /**
  32902. * Defines how the parser contract is defined.
  32903. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  32904. */
  32905. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  32906. /**
  32907. * Defines how the individual parser contract is defined.
  32908. * These parser can parse an individual asset
  32909. */
  32910. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  32911. /**
  32912. * Base class of the scene acting as a container for the different elements composing a scene.
  32913. * This class is dynamically extended by the different components of the scene increasing
  32914. * flexibility and reducing coupling
  32915. */
  32916. export abstract class AbstractScene {
  32917. /**
  32918. * Stores the list of available parsers in the application.
  32919. */
  32920. private static _BabylonFileParsers;
  32921. /**
  32922. * Stores the list of available individual parsers in the application.
  32923. */
  32924. private static _IndividualBabylonFileParsers;
  32925. /**
  32926. * Adds a parser in the list of available ones
  32927. * @param name Defines the name of the parser
  32928. * @param parser Defines the parser to add
  32929. */
  32930. static AddParser(name: string, parser: BabylonFileParser): void;
  32931. /**
  32932. * Gets a general parser from the list of avaialble ones
  32933. * @param name Defines the name of the parser
  32934. * @returns the requested parser or null
  32935. */
  32936. static GetParser(name: string): Nullable<BabylonFileParser>;
  32937. /**
  32938. * Adds n individual parser in the list of available ones
  32939. * @param name Defines the name of the parser
  32940. * @param parser Defines the parser to add
  32941. */
  32942. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  32943. /**
  32944. * Gets an individual parser from the list of avaialble ones
  32945. * @param name Defines the name of the parser
  32946. * @returns the requested parser or null
  32947. */
  32948. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  32949. /**
  32950. * Parser json data and populate both a scene and its associated container object
  32951. * @param jsonData Defines the data to parse
  32952. * @param scene Defines the scene to parse the data for
  32953. * @param container Defines the container attached to the parsing sequence
  32954. * @param rootUrl Defines the root url of the data
  32955. */
  32956. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  32957. /**
  32958. * Gets the list of root nodes (ie. nodes with no parent)
  32959. */
  32960. rootNodes: Node[];
  32961. /** All of the cameras added to this scene
  32962. * @see http://doc.babylonjs.com/babylon101/cameras
  32963. */
  32964. cameras: Camera[];
  32965. /**
  32966. * All of the lights added to this scene
  32967. * @see http://doc.babylonjs.com/babylon101/lights
  32968. */
  32969. lights: Light[];
  32970. /**
  32971. * All of the (abstract) meshes added to this scene
  32972. */
  32973. meshes: AbstractMesh[];
  32974. /**
  32975. * The list of skeletons added to the scene
  32976. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32977. */
  32978. skeletons: Skeleton[];
  32979. /**
  32980. * All of the particle systems added to this scene
  32981. * @see http://doc.babylonjs.com/babylon101/particles
  32982. */
  32983. particleSystems: IParticleSystem[];
  32984. /**
  32985. * Gets a list of Animations associated with the scene
  32986. */
  32987. animations: Animation[];
  32988. /**
  32989. * All of the animation groups added to this scene
  32990. * @see http://doc.babylonjs.com/how_to/group
  32991. */
  32992. animationGroups: AnimationGroup[];
  32993. /**
  32994. * All of the multi-materials added to this scene
  32995. * @see http://doc.babylonjs.com/how_to/multi_materials
  32996. */
  32997. multiMaterials: MultiMaterial[];
  32998. /**
  32999. * All of the materials added to this scene
  33000. * In the context of a Scene, it is not supposed to be modified manually.
  33001. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33002. * Note also that the order of the Material wihin the array is not significant and might change.
  33003. * @see http://doc.babylonjs.com/babylon101/materials
  33004. */
  33005. materials: Material[];
  33006. /**
  33007. * The list of morph target managers added to the scene
  33008. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33009. */
  33010. morphTargetManagers: MorphTargetManager[];
  33011. /**
  33012. * The list of geometries used in the scene.
  33013. */
  33014. geometries: Geometry[];
  33015. /**
  33016. * All of the tranform nodes added to this scene
  33017. * In the context of a Scene, it is not supposed to be modified manually.
  33018. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33019. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33020. * @see http://doc.babylonjs.com/how_to/transformnode
  33021. */
  33022. transformNodes: TransformNode[];
  33023. /**
  33024. * ActionManagers available on the scene.
  33025. */
  33026. actionManagers: AbstractActionManager[];
  33027. /**
  33028. * Textures to keep.
  33029. */
  33030. textures: BaseTexture[];
  33031. /**
  33032. * Environment texture for the scene
  33033. */
  33034. environmentTexture: Nullable<BaseTexture>;
  33035. }
  33036. }
  33037. declare module BABYLON {
  33038. /**
  33039. * Defines a sound that can be played in the application.
  33040. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33042. */
  33043. export class Sound {
  33044. /**
  33045. * The name of the sound in the scene.
  33046. */
  33047. name: string;
  33048. /**
  33049. * Does the sound autoplay once loaded.
  33050. */
  33051. autoplay: boolean;
  33052. /**
  33053. * Does the sound loop after it finishes playing once.
  33054. */
  33055. loop: boolean;
  33056. /**
  33057. * Does the sound use a custom attenuation curve to simulate the falloff
  33058. * happening when the source gets further away from the camera.
  33059. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33060. */
  33061. useCustomAttenuation: boolean;
  33062. /**
  33063. * The sound track id this sound belongs to.
  33064. */
  33065. soundTrackId: number;
  33066. /**
  33067. * Is this sound currently played.
  33068. */
  33069. isPlaying: boolean;
  33070. /**
  33071. * Is this sound currently paused.
  33072. */
  33073. isPaused: boolean;
  33074. /**
  33075. * Does this sound enables spatial sound.
  33076. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33077. */
  33078. spatialSound: boolean;
  33079. /**
  33080. * Define the reference distance the sound should be heard perfectly.
  33081. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33082. */
  33083. refDistance: number;
  33084. /**
  33085. * Define the roll off factor of spatial sounds.
  33086. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33087. */
  33088. rolloffFactor: number;
  33089. /**
  33090. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33091. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33092. */
  33093. maxDistance: number;
  33094. /**
  33095. * Define the distance attenuation model the sound will follow.
  33096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33097. */
  33098. distanceModel: string;
  33099. /**
  33100. * @hidden
  33101. * Back Compat
  33102. **/
  33103. onended: () => any;
  33104. /**
  33105. * Observable event when the current playing sound finishes.
  33106. */
  33107. onEndedObservable: Observable<Sound>;
  33108. private _panningModel;
  33109. private _playbackRate;
  33110. private _streaming;
  33111. private _startTime;
  33112. private _startOffset;
  33113. private _position;
  33114. /** @hidden */ positionInEmitterSpace: boolean;
  33115. private _localDirection;
  33116. private _volume;
  33117. private _isReadyToPlay;
  33118. private _isDirectional;
  33119. private _readyToPlayCallback;
  33120. private _audioBuffer;
  33121. private _soundSource;
  33122. private _streamingSource;
  33123. private _soundPanner;
  33124. private _soundGain;
  33125. private _inputAudioNode;
  33126. private _outputAudioNode;
  33127. private _coneInnerAngle;
  33128. private _coneOuterAngle;
  33129. private _coneOuterGain;
  33130. private _scene;
  33131. private _connectedTransformNode;
  33132. private _customAttenuationFunction;
  33133. private _registerFunc;
  33134. private _isOutputConnected;
  33135. private _htmlAudioElement;
  33136. private _urlType;
  33137. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  33138. /**
  33139. * Create a sound and attach it to a scene
  33140. * @param name Name of your sound
  33141. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33142. * @param scene defines the scene the sound belongs to
  33143. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33144. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33145. */
  33146. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33147. /**
  33148. * Release the sound and its associated resources
  33149. */
  33150. dispose(): void;
  33151. /**
  33152. * Gets if the sounds is ready to be played or not.
  33153. * @returns true if ready, otherwise false
  33154. */
  33155. isReady(): boolean;
  33156. private _soundLoaded;
  33157. /**
  33158. * Sets the data of the sound from an audiobuffer
  33159. * @param audioBuffer The audioBuffer containing the data
  33160. */
  33161. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33162. /**
  33163. * Updates the current sounds options such as maxdistance, loop...
  33164. * @param options A JSON object containing values named as the object properties
  33165. */
  33166. updateOptions(options: any): void;
  33167. private _createSpatialParameters;
  33168. private _updateSpatialParameters;
  33169. /**
  33170. * Switch the panning model to HRTF:
  33171. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33172. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33173. */
  33174. switchPanningModelToHRTF(): void;
  33175. /**
  33176. * Switch the panning model to Equal Power:
  33177. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33178. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33179. */
  33180. switchPanningModelToEqualPower(): void;
  33181. private _switchPanningModel;
  33182. /**
  33183. * Connect this sound to a sound track audio node like gain...
  33184. * @param soundTrackAudioNode the sound track audio node to connect to
  33185. */
  33186. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33187. /**
  33188. * Transform this sound into a directional source
  33189. * @param coneInnerAngle Size of the inner cone in degree
  33190. * @param coneOuterAngle Size of the outer cone in degree
  33191. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33192. */
  33193. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33194. /**
  33195. * Gets or sets the inner angle for the directional cone.
  33196. */
  33197. /**
  33198. * Gets or sets the inner angle for the directional cone.
  33199. */
  33200. directionalConeInnerAngle: number;
  33201. /**
  33202. * Gets or sets the outer angle for the directional cone.
  33203. */
  33204. /**
  33205. * Gets or sets the outer angle for the directional cone.
  33206. */
  33207. directionalConeOuterAngle: number;
  33208. /**
  33209. * Sets the position of the emitter if spatial sound is enabled
  33210. * @param newPosition Defines the new posisiton
  33211. */
  33212. setPosition(newPosition: Vector3): void;
  33213. /**
  33214. * Sets the local direction of the emitter if spatial sound is enabled
  33215. * @param newLocalDirection Defines the new local direction
  33216. */
  33217. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33218. private _updateDirection;
  33219. /** @hidden */
  33220. updateDistanceFromListener(): void;
  33221. /**
  33222. * Sets a new custom attenuation function for the sound.
  33223. * @param callback Defines the function used for the attenuation
  33224. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33225. */
  33226. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33227. /**
  33228. * Play the sound
  33229. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33230. * @param offset (optional) Start the sound setting it at a specific time
  33231. */
  33232. play(time?: number, offset?: number): void;
  33233. private _onended;
  33234. /**
  33235. * Stop the sound
  33236. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33237. */
  33238. stop(time?: number): void;
  33239. /**
  33240. * Put the sound in pause
  33241. */
  33242. pause(): void;
  33243. /**
  33244. * Sets a dedicated volume for this sounds
  33245. * @param newVolume Define the new volume of the sound
  33246. * @param time Define in how long the sound should be at this value
  33247. */
  33248. setVolume(newVolume: number, time?: number): void;
  33249. /**
  33250. * Set the sound play back rate
  33251. * @param newPlaybackRate Define the playback rate the sound should be played at
  33252. */
  33253. setPlaybackRate(newPlaybackRate: number): void;
  33254. /**
  33255. * Gets the volume of the sound.
  33256. * @returns the volume of the sound
  33257. */
  33258. getVolume(): number;
  33259. /**
  33260. * Attach the sound to a dedicated mesh
  33261. * @param transformNode The transform node to connect the sound with
  33262. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33263. */
  33264. attachToMesh(transformNode: TransformNode): void;
  33265. /**
  33266. * Detach the sound from the previously attached mesh
  33267. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33268. */
  33269. detachFromMesh(): void;
  33270. private _onRegisterAfterWorldMatrixUpdate;
  33271. /**
  33272. * Clone the current sound in the scene.
  33273. * @returns the new sound clone
  33274. */
  33275. clone(): Nullable<Sound>;
  33276. /**
  33277. * Gets the current underlying audio buffer containing the data
  33278. * @returns the audio buffer
  33279. */
  33280. getAudioBuffer(): Nullable<AudioBuffer>;
  33281. /**
  33282. * Serializes the Sound in a JSON representation
  33283. * @returns the JSON representation of the sound
  33284. */
  33285. serialize(): any;
  33286. /**
  33287. * Parse a JSON representation of a sound to innstantiate in a given scene
  33288. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33289. * @param scene Define the scene the new parsed sound should be created in
  33290. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33291. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33292. * @returns the newly parsed sound
  33293. */
  33294. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33295. }
  33296. }
  33297. declare module BABYLON {
  33298. /**
  33299. * This defines an action helpful to play a defined sound on a triggered action.
  33300. */
  33301. export class PlaySoundAction extends Action {
  33302. private _sound;
  33303. /**
  33304. * Instantiate the action
  33305. * @param triggerOptions defines the trigger options
  33306. * @param sound defines the sound to play
  33307. * @param condition defines the trigger related conditions
  33308. */
  33309. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33310. /** @hidden */ prepare(): void;
  33311. /**
  33312. * Execute the action and play the sound.
  33313. */
  33314. execute(): void;
  33315. /**
  33316. * Serializes the actions and its related information.
  33317. * @param parent defines the object to serialize in
  33318. * @returns the serialized object
  33319. */
  33320. serialize(parent: any): any;
  33321. }
  33322. /**
  33323. * This defines an action helpful to stop a defined sound on a triggered action.
  33324. */
  33325. export class StopSoundAction extends Action {
  33326. private _sound;
  33327. /**
  33328. * Instantiate the action
  33329. * @param triggerOptions defines the trigger options
  33330. * @param sound defines the sound to stop
  33331. * @param condition defines the trigger related conditions
  33332. */
  33333. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33334. /** @hidden */ prepare(): void;
  33335. /**
  33336. * Execute the action and stop the sound.
  33337. */
  33338. execute(): void;
  33339. /**
  33340. * Serializes the actions and its related information.
  33341. * @param parent defines the object to serialize in
  33342. * @returns the serialized object
  33343. */
  33344. serialize(parent: any): any;
  33345. }
  33346. }
  33347. declare module BABYLON {
  33348. /**
  33349. * This defines an action responsible to change the value of a property
  33350. * by interpolating between its current value and the newly set one once triggered.
  33351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33352. */
  33353. export class InterpolateValueAction extends Action {
  33354. /**
  33355. * Defines the path of the property where the value should be interpolated
  33356. */
  33357. propertyPath: string;
  33358. /**
  33359. * Defines the target value at the end of the interpolation.
  33360. */
  33361. value: any;
  33362. /**
  33363. * Defines the time it will take for the property to interpolate to the value.
  33364. */
  33365. duration: number;
  33366. /**
  33367. * Defines if the other scene animations should be stopped when the action has been triggered
  33368. */
  33369. stopOtherAnimations?: boolean;
  33370. /**
  33371. * Defines a callback raised once the interpolation animation has been done.
  33372. */
  33373. onInterpolationDone?: () => void;
  33374. /**
  33375. * Observable triggered once the interpolation animation has been done.
  33376. */
  33377. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33378. private _target;
  33379. private _effectiveTarget;
  33380. private _property;
  33381. /**
  33382. * Instantiate the action
  33383. * @param triggerOptions defines the trigger options
  33384. * @param target defines the object containing the value to interpolate
  33385. * @param propertyPath defines the path to the property in the target object
  33386. * @param value defines the target value at the end of the interpolation
  33387. * @param duration deines the time it will take for the property to interpolate to the value.
  33388. * @param condition defines the trigger related conditions
  33389. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33390. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33391. */
  33392. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33393. /** @hidden */ prepare(): void;
  33394. /**
  33395. * Execute the action starts the value interpolation.
  33396. */
  33397. execute(): void;
  33398. /**
  33399. * Serializes the actions and its related information.
  33400. * @param parent defines the object to serialize in
  33401. * @returns the serialized object
  33402. */
  33403. serialize(parent: any): any;
  33404. }
  33405. }
  33406. declare module BABYLON {
  33407. /**
  33408. * Options allowed during the creation of a sound track.
  33409. */
  33410. export interface ISoundTrackOptions {
  33411. /**
  33412. * The volume the sound track should take during creation
  33413. */
  33414. volume?: number;
  33415. /**
  33416. * Define if the sound track is the main sound track of the scene
  33417. */
  33418. mainTrack?: boolean;
  33419. }
  33420. /**
  33421. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  33422. * It will be also used in a future release to apply effects on a specific track.
  33423. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33424. */
  33425. export class SoundTrack {
  33426. /**
  33427. * The unique identifier of the sound track in the scene.
  33428. */
  33429. id: number;
  33430. /**
  33431. * The list of sounds included in the sound track.
  33432. */
  33433. soundCollection: Array<Sound>;
  33434. private _outputAudioNode;
  33435. private _scene;
  33436. private _isMainTrack;
  33437. private _connectedAnalyser;
  33438. private _options;
  33439. private _isInitialized;
  33440. /**
  33441. * Creates a new sound track.
  33442. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33443. * @param scene Define the scene the sound track belongs to
  33444. * @param options
  33445. */
  33446. constructor(scene: Scene, options?: ISoundTrackOptions);
  33447. private _initializeSoundTrackAudioGraph;
  33448. /**
  33449. * Release the sound track and its associated resources
  33450. */
  33451. dispose(): void;
  33452. /**
  33453. * Adds a sound to this sound track
  33454. * @param sound define the cound to add
  33455. * @ignoreNaming
  33456. */
  33457. AddSound(sound: Sound): void;
  33458. /**
  33459. * Removes a sound to this sound track
  33460. * @param sound define the cound to remove
  33461. * @ignoreNaming
  33462. */
  33463. RemoveSound(sound: Sound): void;
  33464. /**
  33465. * Set a global volume for the full sound track.
  33466. * @param newVolume Define the new volume of the sound track
  33467. */
  33468. setVolume(newVolume: number): void;
  33469. /**
  33470. * Switch the panning model to HRTF:
  33471. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33472. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33473. */
  33474. switchPanningModelToHRTF(): void;
  33475. /**
  33476. * Switch the panning model to Equal Power:
  33477. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33478. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33479. */
  33480. switchPanningModelToEqualPower(): void;
  33481. /**
  33482. * Connect the sound track to an audio analyser allowing some amazing
  33483. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33484. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33485. * @param analyser The analyser to connect to the engine
  33486. */
  33487. connectToAnalyser(analyser: Analyser): void;
  33488. }
  33489. }
  33490. declare module BABYLON {
  33491. interface AbstractScene {
  33492. /**
  33493. * The list of sounds used in the scene.
  33494. */
  33495. sounds: Nullable<Array<Sound>>;
  33496. }
  33497. interface Scene {
  33498. /**
  33499. * @hidden
  33500. * Backing field
  33501. */ mainSoundTrack: SoundTrack;
  33502. /**
  33503. * The main sound track played by the scene.
  33504. * It cotains your primary collection of sounds.
  33505. */
  33506. mainSoundTrack: SoundTrack;
  33507. /**
  33508. * The list of sound tracks added to the scene
  33509. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33510. */
  33511. soundTracks: Nullable<Array<SoundTrack>>;
  33512. /**
  33513. * Gets a sound using a given name
  33514. * @param name defines the name to search for
  33515. * @return the found sound or null if not found at all.
  33516. */
  33517. getSoundByName(name: string): Nullable<Sound>;
  33518. /**
  33519. * Gets or sets if audio support is enabled
  33520. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33521. */
  33522. audioEnabled: boolean;
  33523. /**
  33524. * Gets or sets if audio will be output to headphones
  33525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33526. */
  33527. headphone: boolean;
  33528. }
  33529. /**
  33530. * Defines the sound scene component responsible to manage any sounds
  33531. * in a given scene.
  33532. */
  33533. export class AudioSceneComponent implements ISceneSerializableComponent {
  33534. /**
  33535. * The component name helpfull to identify the component in the list of scene components.
  33536. */
  33537. readonly name: string;
  33538. /**
  33539. * The scene the component belongs to.
  33540. */
  33541. scene: Scene;
  33542. private _audioEnabled;
  33543. /**
  33544. * Gets whether audio is enabled or not.
  33545. * Please use related enable/disable method to switch state.
  33546. */
  33547. readonly audioEnabled: boolean;
  33548. private _headphone;
  33549. /**
  33550. * Gets whether audio is outputing to headphone or not.
  33551. * Please use the according Switch methods to change output.
  33552. */
  33553. readonly headphone: boolean;
  33554. /**
  33555. * Creates a new instance of the component for the given scene
  33556. * @param scene Defines the scene to register the component in
  33557. */
  33558. constructor(scene: Scene);
  33559. /**
  33560. * Registers the component in a given scene
  33561. */
  33562. register(): void;
  33563. /**
  33564. * Rebuilds the elements related to this component in case of
  33565. * context lost for instance.
  33566. */
  33567. rebuild(): void;
  33568. /**
  33569. * Serializes the component data to the specified json object
  33570. * @param serializationObject The object to serialize to
  33571. */
  33572. serialize(serializationObject: any): void;
  33573. /**
  33574. * Adds all the element from the container to the scene
  33575. * @param container the container holding the elements
  33576. */
  33577. addFromContainer(container: AbstractScene): void;
  33578. /**
  33579. * Removes all the elements in the container from the scene
  33580. * @param container contains the elements to remove
  33581. * @param dispose if the removed element should be disposed (default: false)
  33582. */
  33583. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  33584. /**
  33585. * Disposes the component and the associated ressources.
  33586. */
  33587. dispose(): void;
  33588. /**
  33589. * Disables audio in the associated scene.
  33590. */
  33591. disableAudio(): void;
  33592. /**
  33593. * Enables audio in the associated scene.
  33594. */
  33595. enableAudio(): void;
  33596. /**
  33597. * Switch audio to headphone output.
  33598. */
  33599. switchAudioModeForHeadphones(): void;
  33600. /**
  33601. * Switch audio to normal speakers.
  33602. */
  33603. switchAudioModeForNormalSpeakers(): void;
  33604. private _afterRender;
  33605. }
  33606. }
  33607. declare module BABYLON {
  33608. /**
  33609. * Wraps one or more Sound objects and selects one with random weight for playback.
  33610. */
  33611. export class WeightedSound {
  33612. /** When true a Sound will be selected and played when the current playing Sound completes. */
  33613. loop: boolean;
  33614. private _coneInnerAngle;
  33615. private _coneOuterAngle;
  33616. private _volume;
  33617. /** A Sound is currently playing. */
  33618. isPlaying: boolean;
  33619. /** A Sound is currently paused. */
  33620. isPaused: boolean;
  33621. private _sounds;
  33622. private _weights;
  33623. private _currentIndex?;
  33624. /**
  33625. * Creates a new WeightedSound from the list of sounds given.
  33626. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  33627. * @param sounds Array of Sounds that will be selected from.
  33628. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  33629. */
  33630. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  33631. /**
  33632. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  33633. */
  33634. /**
  33635. * The size of cone in degress for a directional sound in which there will be no attenuation.
  33636. */
  33637. directionalConeInnerAngle: number;
  33638. /**
  33639. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33640. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33641. */
  33642. /**
  33643. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33644. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33645. */
  33646. directionalConeOuterAngle: number;
  33647. /**
  33648. * Playback volume.
  33649. */
  33650. /**
  33651. * Playback volume.
  33652. */
  33653. volume: number;
  33654. private _onended;
  33655. /**
  33656. * Suspend playback
  33657. */
  33658. pause(): void;
  33659. /**
  33660. * Stop playback
  33661. */
  33662. stop(): void;
  33663. /**
  33664. * Start playback.
  33665. * @param startOffset Position the clip head at a specific time in seconds.
  33666. */
  33667. play(startOffset?: number): void;
  33668. }
  33669. }
  33670. declare module BABYLON {
  33671. /**
  33672. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  33673. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33674. */
  33675. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  33676. /**
  33677. * Gets the name of the behavior.
  33678. */
  33679. readonly name: string;
  33680. /**
  33681. * The easing function used by animations
  33682. */
  33683. static EasingFunction: BackEase;
  33684. /**
  33685. * The easing mode used by animations
  33686. */
  33687. static EasingMode: number;
  33688. /**
  33689. * The duration of the animation, in milliseconds
  33690. */
  33691. transitionDuration: number;
  33692. /**
  33693. * Length of the distance animated by the transition when lower radius is reached
  33694. */
  33695. lowerRadiusTransitionRange: number;
  33696. /**
  33697. * Length of the distance animated by the transition when upper radius is reached
  33698. */
  33699. upperRadiusTransitionRange: number;
  33700. private _autoTransitionRange;
  33701. /**
  33702. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33703. */
  33704. /**
  33705. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33706. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  33707. */
  33708. autoTransitionRange: boolean;
  33709. private _attachedCamera;
  33710. private _onAfterCheckInputsObserver;
  33711. private _onMeshTargetChangedObserver;
  33712. /**
  33713. * Initializes the behavior.
  33714. */
  33715. init(): void;
  33716. /**
  33717. * Attaches the behavior to its arc rotate camera.
  33718. * @param camera Defines the camera to attach the behavior to
  33719. */
  33720. attach(camera: ArcRotateCamera): void;
  33721. /**
  33722. * Detaches the behavior from its current arc rotate camera.
  33723. */
  33724. detach(): void;
  33725. private _radiusIsAnimating;
  33726. private _radiusBounceTransition;
  33727. private _animatables;
  33728. private _cachedWheelPrecision;
  33729. /**
  33730. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  33731. * @param radiusLimit The limit to check against.
  33732. * @return Bool to indicate if at limit.
  33733. */
  33734. private _isRadiusAtLimit;
  33735. /**
  33736. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  33737. * @param radiusDelta The delta by which to animate to. Can be negative.
  33738. */
  33739. private _applyBoundRadiusAnimation;
  33740. /**
  33741. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  33742. */
  33743. protected _clearAnimationLocks(): void;
  33744. /**
  33745. * Stops and removes all animations that have been applied to the camera
  33746. */
  33747. stopAllAnimations(): void;
  33748. }
  33749. }
  33750. declare module BABYLON {
  33751. /**
  33752. * 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.
  33753. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33754. */
  33755. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  33756. /**
  33757. * Gets the name of the behavior.
  33758. */
  33759. readonly name: string;
  33760. private _mode;
  33761. private _radiusScale;
  33762. private _positionScale;
  33763. private _defaultElevation;
  33764. private _elevationReturnTime;
  33765. private _elevationReturnWaitTime;
  33766. private _zoomStopsAnimation;
  33767. private _framingTime;
  33768. /**
  33769. * The easing function used by animations
  33770. */
  33771. static EasingFunction: ExponentialEase;
  33772. /**
  33773. * The easing mode used by animations
  33774. */
  33775. static EasingMode: number;
  33776. /**
  33777. * Sets the current mode used by the behavior
  33778. */
  33779. /**
  33780. * Gets current mode used by the behavior.
  33781. */
  33782. mode: number;
  33783. /**
  33784. * Sets the scale applied to the radius (1 by default)
  33785. */
  33786. /**
  33787. * Gets the scale applied to the radius
  33788. */
  33789. radiusScale: number;
  33790. /**
  33791. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33792. */
  33793. /**
  33794. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33795. */
  33796. positionScale: number;
  33797. /**
  33798. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33799. * behaviour is triggered, in radians.
  33800. */
  33801. /**
  33802. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33803. * behaviour is triggered, in radians.
  33804. */
  33805. defaultElevation: number;
  33806. /**
  33807. * Sets the time (in milliseconds) taken to return to the default beta position.
  33808. * Negative value indicates camera should not return to default.
  33809. */
  33810. /**
  33811. * Gets the time (in milliseconds) taken to return to the default beta position.
  33812. * Negative value indicates camera should not return to default.
  33813. */
  33814. elevationReturnTime: number;
  33815. /**
  33816. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33817. */
  33818. /**
  33819. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33820. */
  33821. elevationReturnWaitTime: number;
  33822. /**
  33823. * Sets the flag that indicates if user zooming should stop animation.
  33824. */
  33825. /**
  33826. * Gets the flag that indicates if user zooming should stop animation.
  33827. */
  33828. zoomStopsAnimation: boolean;
  33829. /**
  33830. * Sets the transition time when framing the mesh, in milliseconds
  33831. */
  33832. /**
  33833. * Gets the transition time when framing the mesh, in milliseconds
  33834. */
  33835. framingTime: number;
  33836. /**
  33837. * Define if the behavior should automatically change the configured
  33838. * camera limits and sensibilities.
  33839. */
  33840. autoCorrectCameraLimitsAndSensibility: boolean;
  33841. private _onPrePointerObservableObserver;
  33842. private _onAfterCheckInputsObserver;
  33843. private _onMeshTargetChangedObserver;
  33844. private _attachedCamera;
  33845. private _isPointerDown;
  33846. private _lastInteractionTime;
  33847. /**
  33848. * Initializes the behavior.
  33849. */
  33850. init(): void;
  33851. /**
  33852. * Attaches the behavior to its arc rotate camera.
  33853. * @param camera Defines the camera to attach the behavior to
  33854. */
  33855. attach(camera: ArcRotateCamera): void;
  33856. /**
  33857. * Detaches the behavior from its current arc rotate camera.
  33858. */
  33859. detach(): void;
  33860. private _animatables;
  33861. private _betaIsAnimating;
  33862. private _betaTransition;
  33863. private _radiusTransition;
  33864. private _vectorTransition;
  33865. /**
  33866. * Targets the given mesh and updates zoom level accordingly.
  33867. * @param mesh The mesh to target.
  33868. * @param radius Optional. If a cached radius position already exists, overrides default.
  33869. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33870. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33871. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33872. */
  33873. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33874. /**
  33875. * Targets the given mesh with its children and updates zoom level accordingly.
  33876. * @param mesh The mesh to target.
  33877. * @param radius Optional. If a cached radius position already exists, overrides default.
  33878. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33879. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33880. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33881. */
  33882. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33883. /**
  33884. * Targets the given meshes with their children and updates zoom level accordingly.
  33885. * @param meshes The mesh to target.
  33886. * @param radius Optional. If a cached radius position already exists, overrides default.
  33887. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33888. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33889. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33890. */
  33891. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33892. /**
  33893. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  33894. * @param minimumWorld Determines the smaller position of the bounding box extend
  33895. * @param maximumWorld Determines the bigger position of the bounding box extend
  33896. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33897. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33898. */
  33899. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33900. /**
  33901. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  33902. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  33903. * frustum width.
  33904. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  33905. * to fully enclose the mesh in the viewing frustum.
  33906. */
  33907. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  33908. /**
  33909. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  33910. * is automatically returned to its default position (expected to be above ground plane).
  33911. */
  33912. private _maintainCameraAboveGround;
  33913. /**
  33914. * Returns the frustum slope based on the canvas ratio and camera FOV
  33915. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  33916. */
  33917. private _getFrustumSlope;
  33918. /**
  33919. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  33920. */
  33921. private _clearAnimationLocks;
  33922. /**
  33923. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  33924. */
  33925. private _applyUserInteraction;
  33926. /**
  33927. * Stops and removes all animations that have been applied to the camera
  33928. */
  33929. stopAllAnimations(): void;
  33930. /**
  33931. * Gets a value indicating if the user is moving the camera
  33932. */
  33933. readonly isUserIsMoving: boolean;
  33934. /**
  33935. * The camera can move all the way towards the mesh.
  33936. */
  33937. static IgnoreBoundsSizeMode: number;
  33938. /**
  33939. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  33940. */
  33941. static FitFrustumSidesMode: number;
  33942. }
  33943. }
  33944. declare module BABYLON {
  33945. /**
  33946. * Base class for Camera Pointer Inputs.
  33947. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  33948. * for example usage.
  33949. */
  33950. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  33951. /**
  33952. * Defines the camera the input is attached to.
  33953. */
  33954. abstract camera: Camera;
  33955. /**
  33956. * Whether keyboard modifier keys are pressed at time of last mouse event.
  33957. */
  33958. protected _altKey: boolean;
  33959. protected _ctrlKey: boolean;
  33960. protected _metaKey: boolean;
  33961. protected _shiftKey: boolean;
  33962. /**
  33963. * Which mouse buttons were pressed at time of last mouse event.
  33964. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  33965. */
  33966. protected _buttonsPressed: number;
  33967. /**
  33968. * Defines the buttons associated with the input to handle camera move.
  33969. */
  33970. buttons: number[];
  33971. /**
  33972. * Attach the input controls to a specific dom element to get the input from.
  33973. * @param element Defines the element the controls should be listened from
  33974. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33975. */
  33976. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33977. /**
  33978. * Detach the current controls from the specified dom element.
  33979. * @param element Defines the element to stop listening the inputs from
  33980. */
  33981. detachControl(element: Nullable<HTMLElement>): void;
  33982. /**
  33983. * Gets the class name of the current input.
  33984. * @returns the class name
  33985. */
  33986. getClassName(): string;
  33987. /**
  33988. * Get the friendly name associated with the input class.
  33989. * @returns the input friendly name
  33990. */
  33991. getSimpleName(): string;
  33992. /**
  33993. * Called on pointer POINTERDOUBLETAP event.
  33994. * Override this method to provide functionality on POINTERDOUBLETAP event.
  33995. */
  33996. protected onDoubleTap(type: string): void;
  33997. /**
  33998. * Called on pointer POINTERMOVE event if only a single touch is active.
  33999. * Override this method to provide functionality.
  34000. */
  34001. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34002. /**
  34003. * Called on pointer POINTERMOVE event if multiple touches are active.
  34004. * Override this method to provide functionality.
  34005. */
  34006. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34007. /**
  34008. * Called on JS contextmenu event.
  34009. * Override this method to provide functionality.
  34010. */
  34011. protected onContextMenu(evt: PointerEvent): void;
  34012. /**
  34013. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34014. * press.
  34015. * Override this method to provide functionality.
  34016. */
  34017. protected onButtonDown(evt: PointerEvent): void;
  34018. /**
  34019. * Called each time a new POINTERUP event occurs. Ie, for each button
  34020. * release.
  34021. * Override this method to provide functionality.
  34022. */
  34023. protected onButtonUp(evt: PointerEvent): void;
  34024. /**
  34025. * Called when window becomes inactive.
  34026. * Override this method to provide functionality.
  34027. */
  34028. protected onLostFocus(): void;
  34029. private _pointerInput;
  34030. private _observer;
  34031. private _onLostFocus;
  34032. private pointA;
  34033. private pointB;
  34034. }
  34035. }
  34036. declare module BABYLON {
  34037. /**
  34038. * Manage the pointers inputs to control an arc rotate camera.
  34039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34040. */
  34041. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34042. /**
  34043. * Defines the camera the input is attached to.
  34044. */
  34045. camera: ArcRotateCamera;
  34046. /**
  34047. * Gets the class name of the current input.
  34048. * @returns the class name
  34049. */
  34050. getClassName(): string;
  34051. /**
  34052. * Defines the buttons associated with the input to handle camera move.
  34053. */
  34054. buttons: number[];
  34055. /**
  34056. * Defines the pointer angular sensibility along the X axis or how fast is
  34057. * the camera rotating.
  34058. */
  34059. angularSensibilityX: number;
  34060. /**
  34061. * Defines the pointer angular sensibility along the Y axis or how fast is
  34062. * the camera rotating.
  34063. */
  34064. angularSensibilityY: number;
  34065. /**
  34066. * Defines the pointer pinch precision or how fast is the camera zooming.
  34067. */
  34068. pinchPrecision: number;
  34069. /**
  34070. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34071. * from 0.
  34072. * It defines the percentage of current camera.radius to use as delta when
  34073. * pinch zoom is used.
  34074. */
  34075. pinchDeltaPercentage: number;
  34076. /**
  34077. * Defines the pointer panning sensibility or how fast is the camera moving.
  34078. */
  34079. panningSensibility: number;
  34080. /**
  34081. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34082. */
  34083. multiTouchPanning: boolean;
  34084. /**
  34085. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34086. * zoom (pinch) through multitouch.
  34087. */
  34088. multiTouchPanAndZoom: boolean;
  34089. /**
  34090. * Revers pinch action direction.
  34091. */
  34092. pinchInwards: boolean;
  34093. private _isPanClick;
  34094. private _twoFingerActivityCount;
  34095. private _isPinching;
  34096. /**
  34097. * Called on pointer POINTERMOVE event if only a single touch is active.
  34098. */
  34099. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34100. /**
  34101. * Called on pointer POINTERDOUBLETAP event.
  34102. */
  34103. protected onDoubleTap(type: string): void;
  34104. /**
  34105. * Called on pointer POINTERMOVE event if multiple touches are active.
  34106. */
  34107. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34108. /**
  34109. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34110. * press.
  34111. */
  34112. protected onButtonDown(evt: PointerEvent): void;
  34113. /**
  34114. * Called each time a new POINTERUP event occurs. Ie, for each button
  34115. * release.
  34116. */
  34117. protected onButtonUp(evt: PointerEvent): void;
  34118. /**
  34119. * Called when window becomes inactive.
  34120. */
  34121. protected onLostFocus(): void;
  34122. }
  34123. }
  34124. declare module BABYLON {
  34125. /**
  34126. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34127. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34128. */
  34129. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34130. /**
  34131. * Defines the camera the input is attached to.
  34132. */
  34133. camera: ArcRotateCamera;
  34134. /**
  34135. * Defines the list of key codes associated with the up action (increase alpha)
  34136. */
  34137. keysUp: number[];
  34138. /**
  34139. * Defines the list of key codes associated with the down action (decrease alpha)
  34140. */
  34141. keysDown: number[];
  34142. /**
  34143. * Defines the list of key codes associated with the left action (increase beta)
  34144. */
  34145. keysLeft: number[];
  34146. /**
  34147. * Defines the list of key codes associated with the right action (decrease beta)
  34148. */
  34149. keysRight: number[];
  34150. /**
  34151. * Defines the list of key codes associated with the reset action.
  34152. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34153. */
  34154. keysReset: number[];
  34155. /**
  34156. * Defines the panning sensibility of the inputs.
  34157. * (How fast is the camera paning)
  34158. */
  34159. panningSensibility: number;
  34160. /**
  34161. * Defines the zooming sensibility of the inputs.
  34162. * (How fast is the camera zooming)
  34163. */
  34164. zoomingSensibility: number;
  34165. /**
  34166. * Defines wether maintaining the alt key down switch the movement mode from
  34167. * orientation to zoom.
  34168. */
  34169. useAltToZoom: boolean;
  34170. /**
  34171. * Rotation speed of the camera
  34172. */
  34173. angularSpeed: number;
  34174. private _keys;
  34175. private _ctrlPressed;
  34176. private _altPressed;
  34177. private _onCanvasBlurObserver;
  34178. private _onKeyboardObserver;
  34179. private _engine;
  34180. private _scene;
  34181. /**
  34182. * Attach the input controls to a specific dom element to get the input from.
  34183. * @param element Defines the element the controls should be listened from
  34184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34185. */
  34186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34187. /**
  34188. * Detach the current controls from the specified dom element.
  34189. * @param element Defines the element to stop listening the inputs from
  34190. */
  34191. detachControl(element: Nullable<HTMLElement>): void;
  34192. /**
  34193. * Update the current camera state depending on the inputs that have been used this frame.
  34194. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34195. */
  34196. checkInputs(): void;
  34197. /**
  34198. * Gets the class name of the current intput.
  34199. * @returns the class name
  34200. */
  34201. getClassName(): string;
  34202. /**
  34203. * Get the friendly name associated with the input class.
  34204. * @returns the input friendly name
  34205. */
  34206. getSimpleName(): string;
  34207. }
  34208. }
  34209. declare module BABYLON {
  34210. /**
  34211. * Manage the mouse wheel inputs to control an arc rotate camera.
  34212. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34213. */
  34214. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34215. /**
  34216. * Defines the camera the input is attached to.
  34217. */
  34218. camera: ArcRotateCamera;
  34219. /**
  34220. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34221. */
  34222. wheelPrecision: number;
  34223. /**
  34224. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34225. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34226. */
  34227. wheelDeltaPercentage: number;
  34228. private _wheel;
  34229. private _observer;
  34230. /**
  34231. * Attach the input controls to a specific dom element to get the input from.
  34232. * @param element Defines the element the controls should be listened from
  34233. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34234. */
  34235. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34236. /**
  34237. * Detach the current controls from the specified dom element.
  34238. * @param element Defines the element to stop listening the inputs from
  34239. */
  34240. detachControl(element: Nullable<HTMLElement>): void;
  34241. /**
  34242. * Gets the class name of the current intput.
  34243. * @returns the class name
  34244. */
  34245. getClassName(): string;
  34246. /**
  34247. * Get the friendly name associated with the input class.
  34248. * @returns the input friendly name
  34249. */
  34250. getSimpleName(): string;
  34251. }
  34252. }
  34253. declare module BABYLON {
  34254. /**
  34255. * Default Inputs manager for the ArcRotateCamera.
  34256. * It groups all the default supported inputs for ease of use.
  34257. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34258. */
  34259. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34260. /**
  34261. * Instantiates a new ArcRotateCameraInputsManager.
  34262. * @param camera Defines the camera the inputs belong to
  34263. */
  34264. constructor(camera: ArcRotateCamera);
  34265. /**
  34266. * Add mouse wheel input support to the input manager.
  34267. * @returns the current input manager
  34268. */
  34269. addMouseWheel(): ArcRotateCameraInputsManager;
  34270. /**
  34271. * Add pointers input support to the input manager.
  34272. * @returns the current input manager
  34273. */
  34274. addPointers(): ArcRotateCameraInputsManager;
  34275. /**
  34276. * Add keyboard input support to the input manager.
  34277. * @returns the current input manager
  34278. */
  34279. addKeyboard(): ArcRotateCameraInputsManager;
  34280. }
  34281. }
  34282. declare module BABYLON {
  34283. /**
  34284. * This represents an orbital type of camera.
  34285. *
  34286. * 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.
  34287. * 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.
  34288. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34289. */
  34290. export class ArcRotateCamera extends TargetCamera {
  34291. /**
  34292. * Defines the rotation angle of the camera along the longitudinal axis.
  34293. */
  34294. alpha: number;
  34295. /**
  34296. * Defines the rotation angle of the camera along the latitudinal axis.
  34297. */
  34298. beta: number;
  34299. /**
  34300. * Defines the radius of the camera from it s target point.
  34301. */
  34302. radius: number;
  34303. protected _target: Vector3;
  34304. protected _targetHost: Nullable<AbstractMesh>;
  34305. /**
  34306. * Defines the target point of the camera.
  34307. * The camera looks towards it form the radius distance.
  34308. */
  34309. target: Vector3;
  34310. /**
  34311. * Define the current local position of the camera in the scene
  34312. */
  34313. position: Vector3;
  34314. /**
  34315. * Current inertia value on the longitudinal axis.
  34316. * The bigger this number the longer it will take for the camera to stop.
  34317. */
  34318. inertialAlphaOffset: number;
  34319. /**
  34320. * Current inertia value on the latitudinal axis.
  34321. * The bigger this number the longer it will take for the camera to stop.
  34322. */
  34323. inertialBetaOffset: number;
  34324. /**
  34325. * Current inertia value on the radius axis.
  34326. * The bigger this number the longer it will take for the camera to stop.
  34327. */
  34328. inertialRadiusOffset: number;
  34329. /**
  34330. * Minimum allowed angle on the longitudinal axis.
  34331. * This can help limiting how the Camera is able to move in the scene.
  34332. */
  34333. lowerAlphaLimit: Nullable<number>;
  34334. /**
  34335. * Maximum allowed angle on the longitudinal axis.
  34336. * This can help limiting how the Camera is able to move in the scene.
  34337. */
  34338. upperAlphaLimit: Nullable<number>;
  34339. /**
  34340. * Minimum allowed angle on the latitudinal axis.
  34341. * This can help limiting how the Camera is able to move in the scene.
  34342. */
  34343. lowerBetaLimit: number;
  34344. /**
  34345. * Maximum allowed angle on the latitudinal axis.
  34346. * This can help limiting how the Camera is able to move in the scene.
  34347. */
  34348. upperBetaLimit: number;
  34349. /**
  34350. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34351. * This can help limiting how the Camera is able to move in the scene.
  34352. */
  34353. lowerRadiusLimit: Nullable<number>;
  34354. /**
  34355. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34356. * This can help limiting how the Camera is able to move in the scene.
  34357. */
  34358. upperRadiusLimit: Nullable<number>;
  34359. /**
  34360. * Defines the current inertia value used during panning of the camera along the X axis.
  34361. */
  34362. inertialPanningX: number;
  34363. /**
  34364. * Defines the current inertia value used during panning of the camera along the Y axis.
  34365. */
  34366. inertialPanningY: number;
  34367. /**
  34368. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34369. * Basically if your fingers moves away from more than this distance you will be considered
  34370. * in pinch mode.
  34371. */
  34372. pinchToPanMaxDistance: number;
  34373. /**
  34374. * Defines the maximum distance the camera can pan.
  34375. * This could help keeping the cammera always in your scene.
  34376. */
  34377. panningDistanceLimit: Nullable<number>;
  34378. /**
  34379. * Defines the target of the camera before paning.
  34380. */
  34381. panningOriginTarget: Vector3;
  34382. /**
  34383. * Defines the value of the inertia used during panning.
  34384. * 0 would mean stop inertia and one would mean no decelleration at all.
  34385. */
  34386. panningInertia: number;
  34387. /**
  34388. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34389. */
  34390. angularSensibilityX: number;
  34391. /**
  34392. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34393. */
  34394. angularSensibilityY: number;
  34395. /**
  34396. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34397. */
  34398. pinchPrecision: number;
  34399. /**
  34400. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34401. * It will be used instead of pinchDeltaPrecision if different from 0.
  34402. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34403. */
  34404. pinchDeltaPercentage: number;
  34405. /**
  34406. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34407. */
  34408. panningSensibility: number;
  34409. /**
  34410. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34411. */
  34412. keysUp: number[];
  34413. /**
  34414. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34415. */
  34416. keysDown: number[];
  34417. /**
  34418. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34419. */
  34420. keysLeft: number[];
  34421. /**
  34422. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34423. */
  34424. keysRight: number[];
  34425. /**
  34426. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34427. */
  34428. wheelPrecision: number;
  34429. /**
  34430. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34431. * It will be used instead of pinchDeltaPrecision if different from 0.
  34432. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34433. */
  34434. wheelDeltaPercentage: number;
  34435. /**
  34436. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34437. */
  34438. zoomOnFactor: number;
  34439. /**
  34440. * Defines a screen offset for the camera position.
  34441. */
  34442. targetScreenOffset: Vector2;
  34443. /**
  34444. * Allows the camera to be completely reversed.
  34445. * If false the camera can not arrive upside down.
  34446. */
  34447. allowUpsideDown: boolean;
  34448. /**
  34449. * Define if double tap/click is used to restore the previously saved state of the camera.
  34450. */
  34451. useInputToRestoreState: boolean;
  34452. /** @hidden */ viewMatrix: Matrix;
  34453. /** @hidden */ useCtrlForPanning: boolean;
  34454. /** @hidden */ panningMouseButton: number;
  34455. /**
  34456. * Defines the input associated to the camera.
  34457. */
  34458. inputs: ArcRotateCameraInputsManager;
  34459. /** @hidden */ reset: () => void;
  34460. /**
  34461. * Defines the allowed panning axis.
  34462. */
  34463. panningAxis: Vector3;
  34464. protected _localDirection: Vector3;
  34465. protected _transformedDirection: Vector3;
  34466. private _bouncingBehavior;
  34467. /**
  34468. * Gets the bouncing behavior of the camera if it has been enabled.
  34469. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34470. */
  34471. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  34472. /**
  34473. * Defines if the bouncing behavior of the camera is enabled on the camera.
  34474. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34475. */
  34476. useBouncingBehavior: boolean;
  34477. private _framingBehavior;
  34478. /**
  34479. * Gets the framing behavior of the camera if it has been enabled.
  34480. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34481. */
  34482. readonly framingBehavior: Nullable<FramingBehavior>;
  34483. /**
  34484. * Defines if the framing behavior of the camera is enabled on the camera.
  34485. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34486. */
  34487. useFramingBehavior: boolean;
  34488. private _autoRotationBehavior;
  34489. /**
  34490. * Gets the auto rotation behavior of the camera if it has been enabled.
  34491. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34492. */
  34493. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  34494. /**
  34495. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  34496. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34497. */
  34498. useAutoRotationBehavior: boolean;
  34499. /**
  34500. * Observable triggered when the mesh target has been changed on the camera.
  34501. */
  34502. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  34503. /**
  34504. * Event raised when the camera is colliding with a mesh.
  34505. */
  34506. onCollide: (collidedMesh: AbstractMesh) => void;
  34507. /**
  34508. * Defines whether the camera should check collision with the objects oh the scene.
  34509. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  34510. */
  34511. checkCollisions: boolean;
  34512. /**
  34513. * Defines the collision radius of the camera.
  34514. * This simulates a sphere around the camera.
  34515. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  34516. */
  34517. collisionRadius: Vector3;
  34518. protected _collider: Collider;
  34519. protected _previousPosition: Vector3;
  34520. protected _collisionVelocity: Vector3;
  34521. protected _newPosition: Vector3;
  34522. protected _previousAlpha: number;
  34523. protected _previousBeta: number;
  34524. protected _previousRadius: number;
  34525. protected _collisionTriggered: boolean;
  34526. protected _targetBoundingCenter: Nullable<Vector3>;
  34527. private _computationVector;
  34528. private _tempAxisVector;
  34529. private _tempAxisRotationMatrix;
  34530. /**
  34531. * Instantiates a new ArcRotateCamera in a given scene
  34532. * @param name Defines the name of the camera
  34533. * @param alpha Defines the camera rotation along the logitudinal axis
  34534. * @param beta Defines the camera rotation along the latitudinal axis
  34535. * @param radius Defines the camera distance from its target
  34536. * @param target Defines the camera target
  34537. * @param scene Defines the scene the camera belongs to
  34538. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  34539. */
  34540. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34541. /** @hidden */ initCache(): void;
  34542. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  34543. protected _getTargetPosition(): Vector3;
  34544. private _storedAlpha;
  34545. private _storedBeta;
  34546. private _storedRadius;
  34547. private _storedTarget;
  34548. /**
  34549. * Stores the current state of the camera (alpha, beta, radius and target)
  34550. * @returns the camera itself
  34551. */
  34552. storeState(): Camera;
  34553. /**
  34554. * @hidden
  34555. * Restored camera state. You must call storeState() first
  34556. */ restoreStateValues(): boolean;
  34557. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  34558. /**
  34559. * Attached controls to the current camera.
  34560. * @param element Defines the element the controls should be listened from
  34561. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34562. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  34563. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  34564. */
  34565. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  34566. /**
  34567. * Detach the current controls from the camera.
  34568. * The camera will stop reacting to inputs.
  34569. * @param element Defines the element to stop listening the inputs from
  34570. */
  34571. detachControl(element: HTMLElement): void;
  34572. /** @hidden */ checkInputs(): void;
  34573. protected _checkLimits(): void;
  34574. /**
  34575. * Rebuilds angles (alpha, beta) and radius from the give position and target
  34576. */
  34577. rebuildAnglesAndRadius(): void;
  34578. /**
  34579. * Use a position to define the current camera related information like aplha, beta and radius
  34580. * @param position Defines the position to set the camera at
  34581. */
  34582. setPosition(position: Vector3): void;
  34583. /**
  34584. * Defines the target the camera should look at.
  34585. * This will automatically adapt alpha beta and radius to fit within the new target.
  34586. * @param target Defines the new target as a Vector or a mesh
  34587. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  34588. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  34589. */
  34590. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  34591. /** @hidden */ getViewMatrix(): Matrix;
  34592. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  34593. /**
  34594. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  34595. * @param meshes Defines the mesh to zoom on
  34596. * @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)
  34597. */
  34598. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  34599. /**
  34600. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  34601. * The target will be changed but the radius
  34602. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  34603. * @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)
  34604. */
  34605. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  34606. min: Vector3;
  34607. max: Vector3;
  34608. distance: number;
  34609. }, doNotUpdateMaxZ?: boolean): void;
  34610. /**
  34611. * @override
  34612. * Override Camera.createRigCamera
  34613. */
  34614. createRigCamera(name: string, cameraIndex: number): Camera;
  34615. /**
  34616. * @hidden
  34617. * @override
  34618. * Override Camera._updateRigCameras
  34619. */ updateRigCameras(): void;
  34620. /**
  34621. * Destroy the camera and release the current resources hold by it.
  34622. */
  34623. dispose(): void;
  34624. /**
  34625. * Gets the current object class name.
  34626. * @return the class name
  34627. */
  34628. getClassName(): string;
  34629. }
  34630. }
  34631. declare module BABYLON {
  34632. /**
  34633. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  34634. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34635. */
  34636. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  34637. /**
  34638. * Gets the name of the behavior.
  34639. */
  34640. readonly name: string;
  34641. private _zoomStopsAnimation;
  34642. private _idleRotationSpeed;
  34643. private _idleRotationWaitTime;
  34644. private _idleRotationSpinupTime;
  34645. /**
  34646. * Sets the flag that indicates if user zooming should stop animation.
  34647. */
  34648. /**
  34649. * Gets the flag that indicates if user zooming should stop animation.
  34650. */
  34651. zoomStopsAnimation: boolean;
  34652. /**
  34653. * Sets the default speed at which the camera rotates around the model.
  34654. */
  34655. /**
  34656. * Gets the default speed at which the camera rotates around the model.
  34657. */
  34658. idleRotationSpeed: number;
  34659. /**
  34660. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  34661. */
  34662. /**
  34663. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  34664. */
  34665. idleRotationWaitTime: number;
  34666. /**
  34667. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34668. */
  34669. /**
  34670. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34671. */
  34672. idleRotationSpinupTime: number;
  34673. /**
  34674. * Gets a value indicating if the camera is currently rotating because of this behavior
  34675. */
  34676. readonly rotationInProgress: boolean;
  34677. private _onPrePointerObservableObserver;
  34678. private _onAfterCheckInputsObserver;
  34679. private _attachedCamera;
  34680. private _isPointerDown;
  34681. private _lastFrameTime;
  34682. private _lastInteractionTime;
  34683. private _cameraRotationSpeed;
  34684. /**
  34685. * Initializes the behavior.
  34686. */
  34687. init(): void;
  34688. /**
  34689. * Attaches the behavior to its arc rotate camera.
  34690. * @param camera Defines the camera to attach the behavior to
  34691. */
  34692. attach(camera: ArcRotateCamera): void;
  34693. /**
  34694. * Detaches the behavior from its current arc rotate camera.
  34695. */
  34696. detach(): void;
  34697. /**
  34698. * Returns true if user is scrolling.
  34699. * @return true if user is scrolling.
  34700. */
  34701. private _userIsZooming;
  34702. private _lastFrameRadius;
  34703. private _shouldAnimationStopForInteraction;
  34704. /**
  34705. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34706. */
  34707. private _applyUserInteraction;
  34708. private _userIsMoving;
  34709. }
  34710. }
  34711. declare module BABYLON {
  34712. /**
  34713. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  34714. */
  34715. export class AttachToBoxBehavior implements Behavior<Mesh> {
  34716. private ui;
  34717. /**
  34718. * The name of the behavior
  34719. */
  34720. name: string;
  34721. /**
  34722. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  34723. */
  34724. distanceAwayFromFace: number;
  34725. /**
  34726. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  34727. */
  34728. distanceAwayFromBottomOfFace: number;
  34729. private _faceVectors;
  34730. private _target;
  34731. private _scene;
  34732. private _onRenderObserver;
  34733. private _tmpMatrix;
  34734. private _tmpVector;
  34735. /**
  34736. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  34737. * @param ui The transform node that should be attched to the mesh
  34738. */
  34739. constructor(ui: TransformNode);
  34740. /**
  34741. * Initializes the behavior
  34742. */
  34743. init(): void;
  34744. private _closestFace;
  34745. private _zeroVector;
  34746. private _lookAtTmpMatrix;
  34747. private _lookAtToRef;
  34748. /**
  34749. * Attaches the AttachToBoxBehavior to the passed in mesh
  34750. * @param target The mesh that the specified node will be attached to
  34751. */
  34752. attach(target: Mesh): void;
  34753. /**
  34754. * Detaches the behavior from the mesh
  34755. */
  34756. detach(): void;
  34757. }
  34758. }
  34759. declare module BABYLON {
  34760. /**
  34761. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  34762. */
  34763. export class FadeInOutBehavior implements Behavior<Mesh> {
  34764. /**
  34765. * Time in milliseconds to delay before fading in (Default: 0)
  34766. */
  34767. delay: number;
  34768. /**
  34769. * Time in milliseconds for the mesh to fade in (Default: 300)
  34770. */
  34771. fadeInTime: number;
  34772. private _millisecondsPerFrame;
  34773. private _hovered;
  34774. private _hoverValue;
  34775. private _ownerNode;
  34776. /**
  34777. * Instatiates the FadeInOutBehavior
  34778. */
  34779. constructor();
  34780. /**
  34781. * The name of the behavior
  34782. */
  34783. readonly name: string;
  34784. /**
  34785. * Initializes the behavior
  34786. */
  34787. init(): void;
  34788. /**
  34789. * Attaches the fade behavior on the passed in mesh
  34790. * @param ownerNode The mesh that will be faded in/out once attached
  34791. */
  34792. attach(ownerNode: Mesh): void;
  34793. /**
  34794. * Detaches the behavior from the mesh
  34795. */
  34796. detach(): void;
  34797. /**
  34798. * Triggers the mesh to begin fading in or out
  34799. * @param value if the object should fade in or out (true to fade in)
  34800. */
  34801. fadeIn(value: boolean): void;
  34802. private _update;
  34803. private _setAllVisibility;
  34804. }
  34805. }
  34806. declare module BABYLON {
  34807. /**
  34808. * Class containing a set of static utilities functions for managing Pivots
  34809. * @hidden
  34810. */
  34811. export class PivotTools {
  34812. private static _PivotCached;
  34813. private static _OldPivotPoint;
  34814. private static _PivotTranslation;
  34815. private static _PivotTmpVector;
  34816. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  34817. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  34818. }
  34819. }
  34820. declare module BABYLON {
  34821. /**
  34822. * Class containing static functions to help procedurally build meshes
  34823. */
  34824. export class PlaneBuilder {
  34825. /**
  34826. * Creates a plane mesh
  34827. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  34828. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  34829. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  34830. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34831. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34833. * @param name defines the name of the mesh
  34834. * @param options defines the options used to create the mesh
  34835. * @param scene defines the hosting scene
  34836. * @returns the plane mesh
  34837. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  34838. */
  34839. static CreatePlane(name: string, options: {
  34840. size?: number;
  34841. width?: number;
  34842. height?: number;
  34843. sideOrientation?: number;
  34844. frontUVs?: Vector4;
  34845. backUVs?: Vector4;
  34846. updatable?: boolean;
  34847. sourcePlane?: Plane;
  34848. }, scene: Scene): Mesh;
  34849. }
  34850. }
  34851. declare module BABYLON {
  34852. /**
  34853. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  34854. */
  34855. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  34856. private static _AnyMouseID;
  34857. private _attachedNode;
  34858. private _dragPlane;
  34859. private _scene;
  34860. private _pointerObserver;
  34861. private _beforeRenderObserver;
  34862. private static _planeScene;
  34863. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  34864. /**
  34865. * 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)
  34866. */
  34867. maxDragAngle: number;
  34868. /**
  34869. * @hidden
  34870. */ useAlternatePickedPointAboveMaxDragAngle: boolean;
  34871. /**
  34872. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  34873. */
  34874. currentDraggingPointerID: number;
  34875. /**
  34876. * The last position where the pointer hit the drag plane in world space
  34877. */
  34878. lastDragPosition: Vector3;
  34879. /**
  34880. * If the behavior is currently in a dragging state
  34881. */
  34882. dragging: boolean;
  34883. /**
  34884. * 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)
  34885. */
  34886. dragDeltaRatio: number;
  34887. /**
  34888. * If the drag plane orientation should be updated during the dragging (Default: true)
  34889. */
  34890. updateDragPlane: boolean;
  34891. private _debugMode;
  34892. private _moving;
  34893. /**
  34894. * Fires each time the attached mesh is dragged with the pointer
  34895. * * delta between last drag position and current drag position in world space
  34896. * * dragDistance along the drag axis
  34897. * * dragPlaneNormal normal of the current drag plane used during the drag
  34898. * * dragPlanePoint in world space where the drag intersects the drag plane
  34899. */
  34900. onDragObservable: Observable<{
  34901. delta: Vector3;
  34902. dragPlanePoint: Vector3;
  34903. dragPlaneNormal: Vector3;
  34904. dragDistance: number;
  34905. pointerId: number;
  34906. }>;
  34907. /**
  34908. * Fires each time a drag begins (eg. mouse down on mesh)
  34909. */
  34910. onDragStartObservable: Observable<{
  34911. dragPlanePoint: Vector3;
  34912. pointerId: number;
  34913. }>;
  34914. /**
  34915. * Fires each time a drag ends (eg. mouse release after drag)
  34916. */
  34917. onDragEndObservable: Observable<{
  34918. dragPlanePoint: Vector3;
  34919. pointerId: number;
  34920. }>;
  34921. /**
  34922. * If the attached mesh should be moved when dragged
  34923. */
  34924. moveAttached: boolean;
  34925. /**
  34926. * If the drag behavior will react to drag events (Default: true)
  34927. */
  34928. enabled: boolean;
  34929. /**
  34930. * If camera controls should be detached during the drag
  34931. */
  34932. detachCameraControls: boolean;
  34933. /**
  34934. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  34935. */
  34936. useObjectOrienationForDragging: boolean;
  34937. private _options;
  34938. /**
  34939. * Creates a pointer drag behavior that can be attached to a mesh
  34940. * @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)
  34941. */
  34942. constructor(options?: {
  34943. dragAxis?: Vector3;
  34944. dragPlaneNormal?: Vector3;
  34945. });
  34946. /**
  34947. * Predicate to determine if it is valid to move the object to a new position when it is moved
  34948. */
  34949. validateDrag: (targetPosition: Vector3) => boolean;
  34950. /**
  34951. * The name of the behavior
  34952. */
  34953. readonly name: string;
  34954. /**
  34955. * Initializes the behavior
  34956. */
  34957. init(): void;
  34958. private _tmpVector;
  34959. private _alternatePickedPoint;
  34960. private _worldDragAxis;
  34961. private _targetPosition;
  34962. private _attachedElement;
  34963. /**
  34964. * Attaches the drag behavior the passed in mesh
  34965. * @param ownerNode The mesh that will be dragged around once attached
  34966. */
  34967. attach(ownerNode: AbstractMesh): void;
  34968. /**
  34969. * Force relase the drag action by code.
  34970. */
  34971. releaseDrag(): void;
  34972. private _startDragRay;
  34973. private _lastPointerRay;
  34974. /**
  34975. * Simulates the start of a pointer drag event on the behavior
  34976. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  34977. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  34978. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  34979. */
  34980. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  34981. private _startDrag;
  34982. private _dragDelta;
  34983. private _moveDrag;
  34984. private _pickWithRayOnDragPlane;
  34985. private _pointA;
  34986. private _pointB;
  34987. private _pointC;
  34988. private _lineA;
  34989. private _lineB;
  34990. private _localAxis;
  34991. private _lookAt;
  34992. private _updateDragPlanePosition;
  34993. /**
  34994. * Detaches the behavior from the mesh
  34995. */
  34996. detach(): void;
  34997. }
  34998. }
  34999. declare module BABYLON {
  35000. /**
  35001. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35002. */
  35003. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35004. private _dragBehaviorA;
  35005. private _dragBehaviorB;
  35006. private _startDistance;
  35007. private _initialScale;
  35008. private _targetScale;
  35009. private _ownerNode;
  35010. private _sceneRenderObserver;
  35011. /**
  35012. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35013. */
  35014. constructor();
  35015. /**
  35016. * The name of the behavior
  35017. */
  35018. readonly name: string;
  35019. /**
  35020. * Initializes the behavior
  35021. */
  35022. init(): void;
  35023. private _getCurrentDistance;
  35024. /**
  35025. * Attaches the scale behavior the passed in mesh
  35026. * @param ownerNode The mesh that will be scaled around once attached
  35027. */
  35028. attach(ownerNode: Mesh): void;
  35029. /**
  35030. * Detaches the behavior from the mesh
  35031. */
  35032. detach(): void;
  35033. }
  35034. }
  35035. declare module BABYLON {
  35036. /**
  35037. * 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
  35038. */
  35039. export class SixDofDragBehavior implements Behavior<Mesh> {
  35040. private static _virtualScene;
  35041. private _ownerNode;
  35042. private _sceneRenderObserver;
  35043. private _scene;
  35044. private _targetPosition;
  35045. private _virtualOriginMesh;
  35046. private _virtualDragMesh;
  35047. private _pointerObserver;
  35048. private _moving;
  35049. private _startingOrientation;
  35050. /**
  35051. * 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)
  35052. */
  35053. private zDragFactor;
  35054. /**
  35055. * If the object should rotate to face the drag origin
  35056. */
  35057. rotateDraggedObject: boolean;
  35058. /**
  35059. * If the behavior is currently in a dragging state
  35060. */
  35061. dragging: boolean;
  35062. /**
  35063. * 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)
  35064. */
  35065. dragDeltaRatio: number;
  35066. /**
  35067. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35068. */
  35069. currentDraggingPointerID: number;
  35070. /**
  35071. * If camera controls should be detached during the drag
  35072. */
  35073. detachCameraControls: boolean;
  35074. /**
  35075. * Fires each time a drag starts
  35076. */
  35077. onDragStartObservable: Observable<{}>;
  35078. /**
  35079. * Fires each time a drag ends (eg. mouse release after drag)
  35080. */
  35081. onDragEndObservable: Observable<{}>;
  35082. /**
  35083. * 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
  35084. */
  35085. constructor();
  35086. /**
  35087. * The name of the behavior
  35088. */
  35089. readonly name: string;
  35090. /**
  35091. * Initializes the behavior
  35092. */
  35093. init(): void;
  35094. /**
  35095. * Attaches the scale behavior the passed in mesh
  35096. * @param ownerNode The mesh that will be scaled around once attached
  35097. */
  35098. attach(ownerNode: Mesh): void;
  35099. /**
  35100. * Detaches the behavior from the mesh
  35101. */
  35102. detach(): void;
  35103. }
  35104. }
  35105. declare module BABYLON {
  35106. /**
  35107. * Class used to apply inverse kinematics to bones
  35108. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35109. */
  35110. export class BoneIKController {
  35111. private static _tmpVecs;
  35112. private static _tmpQuat;
  35113. private static _tmpMats;
  35114. /**
  35115. * Gets or sets the target mesh
  35116. */
  35117. targetMesh: AbstractMesh;
  35118. /** Gets or sets the mesh used as pole */
  35119. poleTargetMesh: AbstractMesh;
  35120. /**
  35121. * Gets or sets the bone used as pole
  35122. */
  35123. poleTargetBone: Nullable<Bone>;
  35124. /**
  35125. * Gets or sets the target position
  35126. */
  35127. targetPosition: Vector3;
  35128. /**
  35129. * Gets or sets the pole target position
  35130. */
  35131. poleTargetPosition: Vector3;
  35132. /**
  35133. * Gets or sets the pole target local offset
  35134. */
  35135. poleTargetLocalOffset: Vector3;
  35136. /**
  35137. * Gets or sets the pole angle
  35138. */
  35139. poleAngle: number;
  35140. /**
  35141. * Gets or sets the mesh associated with the controller
  35142. */
  35143. mesh: AbstractMesh;
  35144. /**
  35145. * 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)
  35146. */
  35147. slerpAmount: number;
  35148. private _bone1Quat;
  35149. private _bone1Mat;
  35150. private _bone2Ang;
  35151. private _bone1;
  35152. private _bone2;
  35153. private _bone1Length;
  35154. private _bone2Length;
  35155. private _maxAngle;
  35156. private _maxReach;
  35157. private _rightHandedSystem;
  35158. private _bendAxis;
  35159. private _slerping;
  35160. private _adjustRoll;
  35161. /**
  35162. * Gets or sets maximum allowed angle
  35163. */
  35164. maxAngle: number;
  35165. /**
  35166. * Creates a new BoneIKController
  35167. * @param mesh defines the mesh to control
  35168. * @param bone defines the bone to control
  35169. * @param options defines options to set up the controller
  35170. */
  35171. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35172. targetMesh?: AbstractMesh;
  35173. poleTargetMesh?: AbstractMesh;
  35174. poleTargetBone?: Bone;
  35175. poleTargetLocalOffset?: Vector3;
  35176. poleAngle?: number;
  35177. bendAxis?: Vector3;
  35178. maxAngle?: number;
  35179. slerpAmount?: number;
  35180. });
  35181. private _setMaxAngle;
  35182. /**
  35183. * Force the controller to update the bones
  35184. */
  35185. update(): void;
  35186. }
  35187. }
  35188. declare module BABYLON {
  35189. /**
  35190. * Class used to make a bone look toward a point in space
  35191. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35192. */
  35193. export class BoneLookController {
  35194. private static _tmpVecs;
  35195. private static _tmpQuat;
  35196. private static _tmpMats;
  35197. /**
  35198. * The target Vector3 that the bone will look at
  35199. */
  35200. target: Vector3;
  35201. /**
  35202. * The mesh that the bone is attached to
  35203. */
  35204. mesh: AbstractMesh;
  35205. /**
  35206. * The bone that will be looking to the target
  35207. */
  35208. bone: Bone;
  35209. /**
  35210. * The up axis of the coordinate system that is used when the bone is rotated
  35211. */
  35212. upAxis: Vector3;
  35213. /**
  35214. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35215. */
  35216. upAxisSpace: Space;
  35217. /**
  35218. * Used to make an adjustment to the yaw of the bone
  35219. */
  35220. adjustYaw: number;
  35221. /**
  35222. * Used to make an adjustment to the pitch of the bone
  35223. */
  35224. adjustPitch: number;
  35225. /**
  35226. * Used to make an adjustment to the roll of the bone
  35227. */
  35228. adjustRoll: number;
  35229. /**
  35230. * 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)
  35231. */
  35232. slerpAmount: number;
  35233. private _minYaw;
  35234. private _maxYaw;
  35235. private _minPitch;
  35236. private _maxPitch;
  35237. private _minYawSin;
  35238. private _minYawCos;
  35239. private _maxYawSin;
  35240. private _maxYawCos;
  35241. private _midYawConstraint;
  35242. private _minPitchTan;
  35243. private _maxPitchTan;
  35244. private _boneQuat;
  35245. private _slerping;
  35246. private _transformYawPitch;
  35247. private _transformYawPitchInv;
  35248. private _firstFrameSkipped;
  35249. private _yawRange;
  35250. private _fowardAxis;
  35251. /**
  35252. * Gets or sets the minimum yaw angle that the bone can look to
  35253. */
  35254. minYaw: number;
  35255. /**
  35256. * Gets or sets the maximum yaw angle that the bone can look to
  35257. */
  35258. maxYaw: number;
  35259. /**
  35260. * Gets or sets the minimum pitch angle that the bone can look to
  35261. */
  35262. minPitch: number;
  35263. /**
  35264. * Gets or sets the maximum pitch angle that the bone can look to
  35265. */
  35266. maxPitch: number;
  35267. /**
  35268. * Create a BoneLookController
  35269. * @param mesh the mesh that the bone belongs to
  35270. * @param bone the bone that will be looking to the target
  35271. * @param target the target Vector3 to look at
  35272. * @param options optional settings:
  35273. * * maxYaw: the maximum angle the bone will yaw to
  35274. * * minYaw: the minimum angle the bone will yaw to
  35275. * * maxPitch: the maximum angle the bone will pitch to
  35276. * * minPitch: the minimum angle the bone will yaw to
  35277. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35278. * * upAxis: the up axis of the coordinate system
  35279. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35280. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35281. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35282. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35283. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35284. * * adjustRoll: used to make an adjustment to the roll of the bone
  35285. **/
  35286. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35287. maxYaw?: number;
  35288. minYaw?: number;
  35289. maxPitch?: number;
  35290. minPitch?: number;
  35291. slerpAmount?: number;
  35292. upAxis?: Vector3;
  35293. upAxisSpace?: Space;
  35294. yawAxis?: Vector3;
  35295. pitchAxis?: Vector3;
  35296. adjustYaw?: number;
  35297. adjustPitch?: number;
  35298. adjustRoll?: number;
  35299. });
  35300. /**
  35301. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35302. */
  35303. update(): void;
  35304. private _getAngleDiff;
  35305. private _getAngleBetween;
  35306. private _isAngleBetween;
  35307. }
  35308. }
  35309. declare module BABYLON {
  35310. /**
  35311. * Manage the gamepad inputs to control an arc rotate camera.
  35312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35313. */
  35314. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35315. /**
  35316. * Defines the camera the input is attached to.
  35317. */
  35318. camera: ArcRotateCamera;
  35319. /**
  35320. * Defines the gamepad the input is gathering event from.
  35321. */
  35322. gamepad: Nullable<Gamepad>;
  35323. /**
  35324. * Defines the gamepad rotation sensiblity.
  35325. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35326. */
  35327. gamepadRotationSensibility: number;
  35328. /**
  35329. * Defines the gamepad move sensiblity.
  35330. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35331. */
  35332. gamepadMoveSensibility: number;
  35333. private _onGamepadConnectedObserver;
  35334. private _onGamepadDisconnectedObserver;
  35335. /**
  35336. * Attach the input controls to a specific dom element to get the input from.
  35337. * @param element Defines the element the controls should be listened from
  35338. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35339. */
  35340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35341. /**
  35342. * Detach the current controls from the specified dom element.
  35343. * @param element Defines the element to stop listening the inputs from
  35344. */
  35345. detachControl(element: Nullable<HTMLElement>): void;
  35346. /**
  35347. * Update the current camera state depending on the inputs that have been used this frame.
  35348. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35349. */
  35350. checkInputs(): void;
  35351. /**
  35352. * Gets the class name of the current intput.
  35353. * @returns the class name
  35354. */
  35355. getClassName(): string;
  35356. /**
  35357. * Get the friendly name associated with the input class.
  35358. * @returns the input friendly name
  35359. */
  35360. getSimpleName(): string;
  35361. }
  35362. }
  35363. declare module BABYLON {
  35364. interface ArcRotateCameraInputsManager {
  35365. /**
  35366. * Add orientation input support to the input manager.
  35367. * @returns the current input manager
  35368. */
  35369. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35370. }
  35371. /**
  35372. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35373. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35374. */
  35375. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35376. /**
  35377. * Defines the camera the input is attached to.
  35378. */
  35379. camera: ArcRotateCamera;
  35380. /**
  35381. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35382. */
  35383. alphaCorrection: number;
  35384. /**
  35385. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35386. */
  35387. gammaCorrection: number;
  35388. private _alpha;
  35389. private _gamma;
  35390. private _dirty;
  35391. private _deviceOrientationHandler;
  35392. /**
  35393. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  35394. */
  35395. constructor();
  35396. /**
  35397. * Attach the input controls to a specific dom element to get the input from.
  35398. * @param element Defines the element the controls should be listened from
  35399. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35400. */
  35401. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35402. /** @hidden */ onOrientationEvent(evt: DeviceOrientationEvent): void;
  35403. /**
  35404. * Update the current camera state depending on the inputs that have been used this frame.
  35405. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35406. */
  35407. checkInputs(): void;
  35408. /**
  35409. * Detach the current controls from the specified dom element.
  35410. * @param element Defines the element to stop listening the inputs from
  35411. */
  35412. detachControl(element: Nullable<HTMLElement>): void;
  35413. /**
  35414. * Gets the class name of the current intput.
  35415. * @returns the class name
  35416. */
  35417. getClassName(): string;
  35418. /**
  35419. * Get the friendly name associated with the input class.
  35420. * @returns the input friendly name
  35421. */
  35422. getSimpleName(): string;
  35423. }
  35424. }
  35425. declare module BABYLON {
  35426. /**
  35427. * Listen to mouse events to control the camera.
  35428. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35429. */
  35430. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  35431. /**
  35432. * Defines the camera the input is attached to.
  35433. */
  35434. camera: FlyCamera;
  35435. /**
  35436. * Defines if touch is enabled. (Default is true.)
  35437. */
  35438. touchEnabled: boolean;
  35439. /**
  35440. * Defines the buttons associated with the input to handle camera rotation.
  35441. */
  35442. buttons: number[];
  35443. /**
  35444. * Assign buttons for Yaw control.
  35445. */
  35446. buttonsYaw: number[];
  35447. /**
  35448. * Assign buttons for Pitch control.
  35449. */
  35450. buttonsPitch: number[];
  35451. /**
  35452. * Assign buttons for Roll control.
  35453. */
  35454. buttonsRoll: number[];
  35455. /**
  35456. * Detect if any button is being pressed while mouse is moved.
  35457. * -1 = Mouse locked.
  35458. * 0 = Left button.
  35459. * 1 = Middle Button.
  35460. * 2 = Right Button.
  35461. */
  35462. activeButton: number;
  35463. /**
  35464. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  35465. * Higher values reduce its sensitivity.
  35466. */
  35467. angularSensibility: number;
  35468. private _mousemoveCallback;
  35469. private _observer;
  35470. private _rollObserver;
  35471. private previousPosition;
  35472. private noPreventDefault;
  35473. private element;
  35474. /**
  35475. * Listen to mouse events to control the camera.
  35476. * @param touchEnabled Define if touch is enabled. (Default is true.)
  35477. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35478. */
  35479. constructor(touchEnabled?: boolean);
  35480. /**
  35481. * Attach the mouse control to the HTML DOM element.
  35482. * @param element Defines the element that listens to the input events.
  35483. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  35484. */
  35485. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35486. /**
  35487. * Detach the current controls from the specified dom element.
  35488. * @param element Defines the element to stop listening the inputs from
  35489. */
  35490. detachControl(element: Nullable<HTMLElement>): void;
  35491. /**
  35492. * Gets the class name of the current input.
  35493. * @returns the class name.
  35494. */
  35495. getClassName(): string;
  35496. /**
  35497. * Get the friendly name associated with the input class.
  35498. * @returns the input's friendly name.
  35499. */
  35500. getSimpleName(): string;
  35501. private _pointerInput;
  35502. private _onMouseMove;
  35503. /**
  35504. * Rotate camera by mouse offset.
  35505. */
  35506. private rotateCamera;
  35507. }
  35508. }
  35509. declare module BABYLON {
  35510. /**
  35511. * Default Inputs manager for the FlyCamera.
  35512. * It groups all the default supported inputs for ease of use.
  35513. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35514. */
  35515. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  35516. /**
  35517. * Instantiates a new FlyCameraInputsManager.
  35518. * @param camera Defines the camera the inputs belong to.
  35519. */
  35520. constructor(camera: FlyCamera);
  35521. /**
  35522. * Add keyboard input support to the input manager.
  35523. * @returns the new FlyCameraKeyboardMoveInput().
  35524. */
  35525. addKeyboard(): FlyCameraInputsManager;
  35526. /**
  35527. * Add mouse input support to the input manager.
  35528. * @param touchEnabled Enable touch screen support.
  35529. * @returns the new FlyCameraMouseInput().
  35530. */
  35531. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  35532. }
  35533. }
  35534. declare module BABYLON {
  35535. /**
  35536. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35537. * such as in a 3D Space Shooter or a Flight Simulator.
  35538. */
  35539. export class FlyCamera extends TargetCamera {
  35540. /**
  35541. * Define the collision ellipsoid of the camera.
  35542. * This is helpful for simulating a camera body, like a player's body.
  35543. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35544. */
  35545. ellipsoid: Vector3;
  35546. /**
  35547. * Define an offset for the position of the ellipsoid around the camera.
  35548. * This can be helpful if the camera is attached away from the player's body center,
  35549. * such as at its head.
  35550. */
  35551. ellipsoidOffset: Vector3;
  35552. /**
  35553. * Enable or disable collisions of the camera with the rest of the scene objects.
  35554. */
  35555. checkCollisions: boolean;
  35556. /**
  35557. * Enable or disable gravity on the camera.
  35558. */
  35559. applyGravity: boolean;
  35560. /**
  35561. * Define the current direction the camera is moving to.
  35562. */
  35563. cameraDirection: Vector3;
  35564. /**
  35565. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  35566. * This overrides and empties cameraRotation.
  35567. */
  35568. rotationQuaternion: Quaternion;
  35569. /**
  35570. * Track Roll to maintain the wanted Rolling when looking around.
  35571. */ trackRoll: number;
  35572. /**
  35573. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  35574. */
  35575. rollCorrect: number;
  35576. /**
  35577. * Mimic a banked turn, Rolling the camera when Yawing.
  35578. * It's recommended to use rollCorrect = 10 for faster banking correction.
  35579. */
  35580. bankedTurn: boolean;
  35581. /**
  35582. * Limit in radians for how much Roll banking will add. (Default: 90°)
  35583. */
  35584. bankedTurnLimit: number;
  35585. /**
  35586. * Value of 0 disables the banked Roll.
  35587. * Value of 1 is equal to the Yaw angle in radians.
  35588. */
  35589. bankedTurnMultiplier: number;
  35590. /**
  35591. * The inputs manager loads all the input sources, such as keyboard and mouse.
  35592. */
  35593. inputs: FlyCameraInputsManager;
  35594. /**
  35595. * Gets the input sensibility for mouse input.
  35596. * Higher values reduce sensitivity.
  35597. */
  35598. /**
  35599. * Sets the input sensibility for a mouse input.
  35600. * Higher values reduce sensitivity.
  35601. */
  35602. angularSensibility: number;
  35603. /**
  35604. * Get the keys for camera movement forward.
  35605. */
  35606. /**
  35607. * Set the keys for camera movement forward.
  35608. */
  35609. keysForward: number[];
  35610. /**
  35611. * Get the keys for camera movement backward.
  35612. */
  35613. keysBackward: number[];
  35614. /**
  35615. * Get the keys for camera movement up.
  35616. */
  35617. /**
  35618. * Set the keys for camera movement up.
  35619. */
  35620. keysUp: number[];
  35621. /**
  35622. * Get the keys for camera movement down.
  35623. */
  35624. /**
  35625. * Set the keys for camera movement down.
  35626. */
  35627. keysDown: number[];
  35628. /**
  35629. * Get the keys for camera movement left.
  35630. */
  35631. /**
  35632. * Set the keys for camera movement left.
  35633. */
  35634. keysLeft: number[];
  35635. /**
  35636. * Set the keys for camera movement right.
  35637. */
  35638. /**
  35639. * Set the keys for camera movement right.
  35640. */
  35641. keysRight: number[];
  35642. /**
  35643. * Event raised when the camera collides with a mesh in the scene.
  35644. */
  35645. onCollide: (collidedMesh: AbstractMesh) => void;
  35646. private _collider;
  35647. private _needMoveForGravity;
  35648. private _oldPosition;
  35649. private _diffPosition;
  35650. private _newPosition;
  35651. /** @hidden */ localDirection: Vector3;
  35652. /** @hidden */ transformedDirection: Vector3;
  35653. /**
  35654. * Instantiates a FlyCamera.
  35655. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35656. * such as in a 3D Space Shooter or a Flight Simulator.
  35657. * @param name Define the name of the camera in the scene.
  35658. * @param position Define the starting position of the camera in the scene.
  35659. * @param scene Define the scene the camera belongs to.
  35660. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  35661. */
  35662. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35663. /**
  35664. * Attach a control to the HTML DOM element.
  35665. * @param element Defines the element that listens to the input events.
  35666. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  35667. */
  35668. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35669. /**
  35670. * Detach a control from the HTML DOM element.
  35671. * The camera will stop reacting to that input.
  35672. * @param element Defines the element that listens to the input events.
  35673. */
  35674. detachControl(element: HTMLElement): void;
  35675. private _collisionMask;
  35676. /**
  35677. * Get the mask that the camera ignores in collision events.
  35678. */
  35679. /**
  35680. * Set the mask that the camera ignores in collision events.
  35681. */
  35682. collisionMask: number;
  35683. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  35684. /** @hidden */
  35685. private _onCollisionPositionChange;
  35686. /** @hidden */ checkInputs(): void;
  35687. /** @hidden */ decideIfNeedsToMove(): boolean;
  35688. /** @hidden */ updatePosition(): void;
  35689. /**
  35690. * Restore the Roll to its target value at the rate specified.
  35691. * @param rate - Higher means slower restoring.
  35692. * @hidden
  35693. */
  35694. restoreRoll(rate: number): void;
  35695. /**
  35696. * Destroy the camera and release the current resources held by it.
  35697. */
  35698. dispose(): void;
  35699. /**
  35700. * Get the current object class name.
  35701. * @returns the class name.
  35702. */
  35703. getClassName(): string;
  35704. }
  35705. }
  35706. declare module BABYLON {
  35707. /**
  35708. * Listen to keyboard events to control the camera.
  35709. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35710. */
  35711. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  35712. /**
  35713. * Defines the camera the input is attached to.
  35714. */
  35715. camera: FlyCamera;
  35716. /**
  35717. * The list of keyboard keys used to control the forward move of the camera.
  35718. */
  35719. keysForward: number[];
  35720. /**
  35721. * The list of keyboard keys used to control the backward move of the camera.
  35722. */
  35723. keysBackward: number[];
  35724. /**
  35725. * The list of keyboard keys used to control the forward move of the camera.
  35726. */
  35727. keysUp: number[];
  35728. /**
  35729. * The list of keyboard keys used to control the backward move of the camera.
  35730. */
  35731. keysDown: number[];
  35732. /**
  35733. * The list of keyboard keys used to control the right strafe move of the camera.
  35734. */
  35735. keysRight: number[];
  35736. /**
  35737. * The list of keyboard keys used to control the left strafe move of the camera.
  35738. */
  35739. keysLeft: number[];
  35740. private _keys;
  35741. private _onCanvasBlurObserver;
  35742. private _onKeyboardObserver;
  35743. private _engine;
  35744. private _scene;
  35745. /**
  35746. * Attach the input controls to a specific dom element to get the input from.
  35747. * @param element Defines the element the controls should be listened from
  35748. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35749. */
  35750. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35751. /**
  35752. * Detach the current controls from the specified dom element.
  35753. * @param element Defines the element to stop listening the inputs from
  35754. */
  35755. detachControl(element: Nullable<HTMLElement>): void;
  35756. /**
  35757. * Gets the class name of the current intput.
  35758. * @returns the class name
  35759. */
  35760. getClassName(): string;
  35761. /** @hidden */ onLostFocus(e: FocusEvent): void;
  35762. /**
  35763. * Get the friendly name associated with the input class.
  35764. * @returns the input friendly name
  35765. */
  35766. getSimpleName(): string;
  35767. /**
  35768. * Update the current camera state depending on the inputs that have been used this frame.
  35769. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35770. */
  35771. checkInputs(): void;
  35772. }
  35773. }
  35774. declare module BABYLON {
  35775. /**
  35776. * Manage the mouse wheel inputs to control a follow camera.
  35777. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35778. */
  35779. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  35780. /**
  35781. * Defines the camera the input is attached to.
  35782. */
  35783. camera: FollowCamera;
  35784. /**
  35785. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  35786. */
  35787. axisControlRadius: boolean;
  35788. /**
  35789. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  35790. */
  35791. axisControlHeight: boolean;
  35792. /**
  35793. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  35794. */
  35795. axisControlRotation: boolean;
  35796. /**
  35797. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  35798. * relation to mouseWheel events.
  35799. */
  35800. wheelPrecision: number;
  35801. /**
  35802. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35803. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35804. */
  35805. wheelDeltaPercentage: number;
  35806. private _wheel;
  35807. private _observer;
  35808. /**
  35809. * Attach the input controls to a specific dom element to get the input from.
  35810. * @param element Defines the element the controls should be listened from
  35811. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35812. */
  35813. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35814. /**
  35815. * Detach the current controls from the specified dom element.
  35816. * @param element Defines the element to stop listening the inputs from
  35817. */
  35818. detachControl(element: Nullable<HTMLElement>): void;
  35819. /**
  35820. * Gets the class name of the current intput.
  35821. * @returns the class name
  35822. */
  35823. getClassName(): string;
  35824. /**
  35825. * Get the friendly name associated with the input class.
  35826. * @returns the input friendly name
  35827. */
  35828. getSimpleName(): string;
  35829. }
  35830. }
  35831. declare module BABYLON {
  35832. /**
  35833. * Manage the pointers inputs to control an follow camera.
  35834. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35835. */
  35836. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  35837. /**
  35838. * Defines the camera the input is attached to.
  35839. */
  35840. camera: FollowCamera;
  35841. /**
  35842. * Gets the class name of the current input.
  35843. * @returns the class name
  35844. */
  35845. getClassName(): string;
  35846. /**
  35847. * Defines the pointer angular sensibility along the X axis or how fast is
  35848. * the camera rotating.
  35849. * A negative number will reverse the axis direction.
  35850. */
  35851. angularSensibilityX: number;
  35852. /**
  35853. * Defines the pointer angular sensibility along the Y axis or how fast is
  35854. * the camera rotating.
  35855. * A negative number will reverse the axis direction.
  35856. */
  35857. angularSensibilityY: number;
  35858. /**
  35859. * Defines the pointer pinch precision or how fast is the camera zooming.
  35860. * A negative number will reverse the axis direction.
  35861. */
  35862. pinchPrecision: number;
  35863. /**
  35864. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35865. * from 0.
  35866. * It defines the percentage of current camera.radius to use as delta when
  35867. * pinch zoom is used.
  35868. */
  35869. pinchDeltaPercentage: number;
  35870. /**
  35871. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  35872. */
  35873. axisXControlRadius: boolean;
  35874. /**
  35875. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  35876. */
  35877. axisXControlHeight: boolean;
  35878. /**
  35879. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  35880. */
  35881. axisXControlRotation: boolean;
  35882. /**
  35883. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  35884. */
  35885. axisYControlRadius: boolean;
  35886. /**
  35887. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  35888. */
  35889. axisYControlHeight: boolean;
  35890. /**
  35891. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  35892. */
  35893. axisYControlRotation: boolean;
  35894. /**
  35895. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  35896. */
  35897. axisPinchControlRadius: boolean;
  35898. /**
  35899. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  35900. */
  35901. axisPinchControlHeight: boolean;
  35902. /**
  35903. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  35904. */
  35905. axisPinchControlRotation: boolean;
  35906. /**
  35907. * Log error messages if basic misconfiguration has occurred.
  35908. */
  35909. warningEnable: boolean;
  35910. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35911. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35912. private _warningCounter;
  35913. private _warning;
  35914. }
  35915. }
  35916. declare module BABYLON {
  35917. /**
  35918. * Default Inputs manager for the FollowCamera.
  35919. * It groups all the default supported inputs for ease of use.
  35920. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35921. */
  35922. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  35923. /**
  35924. * Instantiates a new FollowCameraInputsManager.
  35925. * @param camera Defines the camera the inputs belong to
  35926. */
  35927. constructor(camera: FollowCamera);
  35928. /**
  35929. * Add keyboard input support to the input manager.
  35930. * @returns the current input manager
  35931. */
  35932. addKeyboard(): FollowCameraInputsManager;
  35933. /**
  35934. * Add mouse wheel input support to the input manager.
  35935. * @returns the current input manager
  35936. */
  35937. addMouseWheel(): FollowCameraInputsManager;
  35938. /**
  35939. * Add pointers input support to the input manager.
  35940. * @returns the current input manager
  35941. */
  35942. addPointers(): FollowCameraInputsManager;
  35943. /**
  35944. * Add orientation input support to the input manager.
  35945. * @returns the current input manager
  35946. */
  35947. addVRDeviceOrientation(): FollowCameraInputsManager;
  35948. }
  35949. }
  35950. declare module BABYLON {
  35951. /**
  35952. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  35953. * an arc rotate version arcFollowCamera are available.
  35954. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  35955. */
  35956. export class FollowCamera extends TargetCamera {
  35957. /**
  35958. * Distance the follow camera should follow an object at
  35959. */
  35960. radius: number;
  35961. /**
  35962. * Minimum allowed distance of the camera to the axis of rotation
  35963. * (The camera can not get closer).
  35964. * This can help limiting how the Camera is able to move in the scene.
  35965. */
  35966. lowerRadiusLimit: Nullable<number>;
  35967. /**
  35968. * Maximum allowed distance of the camera to the axis of rotation
  35969. * (The camera can not get further).
  35970. * This can help limiting how the Camera is able to move in the scene.
  35971. */
  35972. upperRadiusLimit: Nullable<number>;
  35973. /**
  35974. * Define a rotation offset between the camera and the object it follows
  35975. */
  35976. rotationOffset: number;
  35977. /**
  35978. * Minimum allowed angle to camera position relative to target object.
  35979. * This can help limiting how the Camera is able to move in the scene.
  35980. */
  35981. lowerRotationOffsetLimit: Nullable<number>;
  35982. /**
  35983. * Maximum allowed angle to camera position relative to target object.
  35984. * This can help limiting how the Camera is able to move in the scene.
  35985. */
  35986. upperRotationOffsetLimit: Nullable<number>;
  35987. /**
  35988. * Define a height offset between the camera and the object it follows.
  35989. * It can help following an object from the top (like a car chaing a plane)
  35990. */
  35991. heightOffset: number;
  35992. /**
  35993. * Minimum allowed height of camera position relative to target object.
  35994. * This can help limiting how the Camera is able to move in the scene.
  35995. */
  35996. lowerHeightOffsetLimit: Nullable<number>;
  35997. /**
  35998. * Maximum allowed height of camera position relative to target object.
  35999. * This can help limiting how the Camera is able to move in the scene.
  36000. */
  36001. upperHeightOffsetLimit: Nullable<number>;
  36002. /**
  36003. * Define how fast the camera can accelerate to follow it s target.
  36004. */
  36005. cameraAcceleration: number;
  36006. /**
  36007. * Define the speed limit of the camera following an object.
  36008. */
  36009. maxCameraSpeed: number;
  36010. /**
  36011. * Define the target of the camera.
  36012. */
  36013. lockedTarget: Nullable<AbstractMesh>;
  36014. /**
  36015. * Defines the input associated with the camera.
  36016. */
  36017. inputs: FollowCameraInputsManager;
  36018. /**
  36019. * Instantiates the follow camera.
  36020. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36021. * @param name Define the name of the camera in the scene
  36022. * @param position Define the position of the camera
  36023. * @param scene Define the scene the camera belong to
  36024. * @param lockedTarget Define the target of the camera
  36025. */
  36026. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36027. private _follow;
  36028. /**
  36029. * Attached controls to the current camera.
  36030. * @param element Defines the element the controls should be listened from
  36031. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36032. */
  36033. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36034. /**
  36035. * Detach the current controls from the camera.
  36036. * The camera will stop reacting to inputs.
  36037. * @param element Defines the element to stop listening the inputs from
  36038. */
  36039. detachControl(element: HTMLElement): void;
  36040. /** @hidden */ checkInputs(): void;
  36041. private _checkLimits;
  36042. /**
  36043. * Gets the camera class name.
  36044. * @returns the class name
  36045. */
  36046. getClassName(): string;
  36047. }
  36048. /**
  36049. * Arc Rotate version of the follow camera.
  36050. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36051. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36052. */
  36053. export class ArcFollowCamera extends TargetCamera {
  36054. /** The longitudinal angle of the camera */
  36055. alpha: number;
  36056. /** The latitudinal angle of the camera */
  36057. beta: number;
  36058. /** The radius of the camera from its target */
  36059. radius: number;
  36060. /** Define the camera target (the messh it should follow) */
  36061. target: Nullable<AbstractMesh>;
  36062. private _cartesianCoordinates;
  36063. /**
  36064. * Instantiates a new ArcFollowCamera
  36065. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36066. * @param name Define the name of the camera
  36067. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36068. * @param beta Define the rotation angle of the camera around the elevation axis
  36069. * @param radius Define the radius of the camera from its target point
  36070. * @param target Define the target of the camera
  36071. * @param scene Define the scene the camera belongs to
  36072. */
  36073. constructor(name: string,
  36074. /** The longitudinal angle of the camera */
  36075. alpha: number,
  36076. /** The latitudinal angle of the camera */
  36077. beta: number,
  36078. /** The radius of the camera from its target */
  36079. radius: number,
  36080. /** Define the camera target (the messh it should follow) */
  36081. target: Nullable<AbstractMesh>, scene: Scene);
  36082. private _follow;
  36083. /** @hidden */ checkInputs(): void;
  36084. /**
  36085. * Returns the class name of the object.
  36086. * It is mostly used internally for serialization purposes.
  36087. */
  36088. getClassName(): string;
  36089. }
  36090. }
  36091. declare module BABYLON {
  36092. /**
  36093. * Manage the keyboard inputs to control the movement of a follow camera.
  36094. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36095. */
  36096. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36097. /**
  36098. * Defines the camera the input is attached to.
  36099. */
  36100. camera: FollowCamera;
  36101. /**
  36102. * Defines the list of key codes associated with the up action (increase heightOffset)
  36103. */
  36104. keysHeightOffsetIncr: number[];
  36105. /**
  36106. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36107. */
  36108. keysHeightOffsetDecr: number[];
  36109. /**
  36110. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36111. */
  36112. keysHeightOffsetModifierAlt: boolean;
  36113. /**
  36114. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36115. */
  36116. keysHeightOffsetModifierCtrl: boolean;
  36117. /**
  36118. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36119. */
  36120. keysHeightOffsetModifierShift: boolean;
  36121. /**
  36122. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36123. */
  36124. keysRotationOffsetIncr: number[];
  36125. /**
  36126. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36127. */
  36128. keysRotationOffsetDecr: number[];
  36129. /**
  36130. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36131. */
  36132. keysRotationOffsetModifierAlt: boolean;
  36133. /**
  36134. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36135. */
  36136. keysRotationOffsetModifierCtrl: boolean;
  36137. /**
  36138. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36139. */
  36140. keysRotationOffsetModifierShift: boolean;
  36141. /**
  36142. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36143. */
  36144. keysRadiusIncr: number[];
  36145. /**
  36146. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36147. */
  36148. keysRadiusDecr: number[];
  36149. /**
  36150. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36151. */
  36152. keysRadiusModifierAlt: boolean;
  36153. /**
  36154. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36155. */
  36156. keysRadiusModifierCtrl: boolean;
  36157. /**
  36158. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36159. */
  36160. keysRadiusModifierShift: boolean;
  36161. /**
  36162. * Defines the rate of change of heightOffset.
  36163. */
  36164. heightSensibility: number;
  36165. /**
  36166. * Defines the rate of change of rotationOffset.
  36167. */
  36168. rotationSensibility: number;
  36169. /**
  36170. * Defines the rate of change of radius.
  36171. */
  36172. radiusSensibility: number;
  36173. private _keys;
  36174. private _ctrlPressed;
  36175. private _altPressed;
  36176. private _shiftPressed;
  36177. private _onCanvasBlurObserver;
  36178. private _onKeyboardObserver;
  36179. private _engine;
  36180. private _scene;
  36181. /**
  36182. * Attach the input controls to a specific dom element to get the input from.
  36183. * @param element Defines the element the controls should be listened from
  36184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36185. */
  36186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36187. /**
  36188. * Detach the current controls from the specified dom element.
  36189. * @param element Defines the element to stop listening the inputs from
  36190. */
  36191. detachControl(element: Nullable<HTMLElement>): void;
  36192. /**
  36193. * Update the current camera state depending on the inputs that have been used this frame.
  36194. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36195. */
  36196. checkInputs(): void;
  36197. /**
  36198. * Gets the class name of the current input.
  36199. * @returns the class name
  36200. */
  36201. getClassName(): string;
  36202. /**
  36203. * Get the friendly name associated with the input class.
  36204. * @returns the input friendly name
  36205. */
  36206. getSimpleName(): string;
  36207. /**
  36208. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36209. * allow modification of the heightOffset value.
  36210. */
  36211. private _modifierHeightOffset;
  36212. /**
  36213. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36214. * allow modification of the rotationOffset value.
  36215. */
  36216. private _modifierRotationOffset;
  36217. /**
  36218. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36219. * allow modification of the radius value.
  36220. */
  36221. private _modifierRadius;
  36222. }
  36223. }
  36224. declare module BABYLON {
  36225. interface FreeCameraInputsManager {
  36226. /**
  36227. * @hidden
  36228. */ deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  36229. /**
  36230. * Add orientation input support to the input manager.
  36231. * @returns the current input manager
  36232. */
  36233. addDeviceOrientation(): FreeCameraInputsManager;
  36234. }
  36235. /**
  36236. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36237. * Screen rotation is taken into account.
  36238. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36239. */
  36240. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36241. private _camera;
  36242. private _screenOrientationAngle;
  36243. private _constantTranform;
  36244. private _screenQuaternion;
  36245. private _alpha;
  36246. private _beta;
  36247. private _gamma;
  36248. /**
  36249. * @hidden
  36250. */ onDeviceOrientationChangedObservable: Observable<void>;
  36251. /**
  36252. * Instantiates a new input
  36253. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36254. */
  36255. constructor();
  36256. /**
  36257. * Define the camera controlled by the input.
  36258. */
  36259. camera: FreeCamera;
  36260. /**
  36261. * Attach the input controls to a specific dom element to get the input from.
  36262. * @param element Defines the element the controls should be listened from
  36263. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36264. */
  36265. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36266. private _orientationChanged;
  36267. private _deviceOrientation;
  36268. /**
  36269. * Detach the current controls from the specified dom element.
  36270. * @param element Defines the element to stop listening the inputs from
  36271. */
  36272. detachControl(element: Nullable<HTMLElement>): void;
  36273. /**
  36274. * Update the current camera state depending on the inputs that have been used this frame.
  36275. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36276. */
  36277. checkInputs(): void;
  36278. /**
  36279. * Gets the class name of the current intput.
  36280. * @returns the class name
  36281. */
  36282. getClassName(): string;
  36283. /**
  36284. * Get the friendly name associated with the input class.
  36285. * @returns the input friendly name
  36286. */
  36287. getSimpleName(): string;
  36288. }
  36289. }
  36290. declare module BABYLON {
  36291. /**
  36292. * Manage the gamepad inputs to control a free camera.
  36293. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36294. */
  36295. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36296. /**
  36297. * Define the camera the input is attached to.
  36298. */
  36299. camera: FreeCamera;
  36300. /**
  36301. * Define the Gamepad controlling the input
  36302. */
  36303. gamepad: Nullable<Gamepad>;
  36304. /**
  36305. * Defines the gamepad rotation sensiblity.
  36306. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36307. */
  36308. gamepadAngularSensibility: number;
  36309. /**
  36310. * Defines the gamepad move sensiblity.
  36311. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36312. */
  36313. gamepadMoveSensibility: number;
  36314. private _onGamepadConnectedObserver;
  36315. private _onGamepadDisconnectedObserver;
  36316. private _cameraTransform;
  36317. private _deltaTransform;
  36318. private _vector3;
  36319. private _vector2;
  36320. /**
  36321. * Attach the input controls to a specific dom element to get the input from.
  36322. * @param element Defines the element the controls should be listened from
  36323. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36324. */
  36325. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36326. /**
  36327. * Detach the current controls from the specified dom element.
  36328. * @param element Defines the element to stop listening the inputs from
  36329. */
  36330. detachControl(element: Nullable<HTMLElement>): void;
  36331. /**
  36332. * Update the current camera state depending on the inputs that have been used this frame.
  36333. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36334. */
  36335. checkInputs(): void;
  36336. /**
  36337. * Gets the class name of the current intput.
  36338. * @returns the class name
  36339. */
  36340. getClassName(): string;
  36341. /**
  36342. * Get the friendly name associated with the input class.
  36343. * @returns the input friendly name
  36344. */
  36345. getSimpleName(): string;
  36346. }
  36347. }
  36348. declare module BABYLON {
  36349. /**
  36350. * Defines the potential axis of a Joystick
  36351. */
  36352. export enum JoystickAxis {
  36353. /** X axis */
  36354. X = 0,
  36355. /** Y axis */
  36356. Y = 1,
  36357. /** Z axis */
  36358. Z = 2
  36359. }
  36360. /**
  36361. * Class used to define virtual joystick (used in touch mode)
  36362. */
  36363. export class VirtualJoystick {
  36364. /**
  36365. * Gets or sets a boolean indicating that left and right values must be inverted
  36366. */
  36367. reverseLeftRight: boolean;
  36368. /**
  36369. * Gets or sets a boolean indicating that up and down values must be inverted
  36370. */
  36371. reverseUpDown: boolean;
  36372. /**
  36373. * Gets the offset value for the position (ie. the change of the position value)
  36374. */
  36375. deltaPosition: Vector3;
  36376. /**
  36377. * Gets a boolean indicating if the virtual joystick was pressed
  36378. */
  36379. pressed: boolean;
  36380. /**
  36381. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36382. */
  36383. static Canvas: Nullable<HTMLCanvasElement>;
  36384. private static _globalJoystickIndex;
  36385. private static vjCanvasContext;
  36386. private static vjCanvasWidth;
  36387. private static vjCanvasHeight;
  36388. private static halfWidth;
  36389. private _action;
  36390. private _axisTargetedByLeftAndRight;
  36391. private _axisTargetedByUpAndDown;
  36392. private _joystickSensibility;
  36393. private _inversedSensibility;
  36394. private _joystickPointerID;
  36395. private _joystickColor;
  36396. private _joystickPointerPos;
  36397. private _joystickPreviousPointerPos;
  36398. private _joystickPointerStartPos;
  36399. private _deltaJoystickVector;
  36400. private _leftJoystick;
  36401. private _touches;
  36402. private _onPointerDownHandlerRef;
  36403. private _onPointerMoveHandlerRef;
  36404. private _onPointerUpHandlerRef;
  36405. private _onResize;
  36406. /**
  36407. * Creates a new virtual joystick
  36408. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36409. */
  36410. constructor(leftJoystick?: boolean);
  36411. /**
  36412. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36413. * @param newJoystickSensibility defines the new sensibility
  36414. */
  36415. setJoystickSensibility(newJoystickSensibility: number): void;
  36416. private _onPointerDown;
  36417. private _onPointerMove;
  36418. private _onPointerUp;
  36419. /**
  36420. * Change the color of the virtual joystick
  36421. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36422. */
  36423. setJoystickColor(newColor: string): void;
  36424. /**
  36425. * Defines a callback to call when the joystick is touched
  36426. * @param action defines the callback
  36427. */
  36428. setActionOnTouch(action: () => any): void;
  36429. /**
  36430. * Defines which axis you'd like to control for left & right
  36431. * @param axis defines the axis to use
  36432. */
  36433. setAxisForLeftRight(axis: JoystickAxis): void;
  36434. /**
  36435. * Defines which axis you'd like to control for up & down
  36436. * @param axis defines the axis to use
  36437. */
  36438. setAxisForUpDown(axis: JoystickAxis): void;
  36439. private _drawVirtualJoystick;
  36440. /**
  36441. * Release internal HTML canvas
  36442. */
  36443. releaseCanvas(): void;
  36444. }
  36445. }
  36446. declare module BABYLON {
  36447. interface FreeCameraInputsManager {
  36448. /**
  36449. * Add virtual joystick input support to the input manager.
  36450. * @returns the current input manager
  36451. */
  36452. addVirtualJoystick(): FreeCameraInputsManager;
  36453. }
  36454. /**
  36455. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36456. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36457. */
  36458. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36459. /**
  36460. * Defines the camera the input is attached to.
  36461. */
  36462. camera: FreeCamera;
  36463. private _leftjoystick;
  36464. private _rightjoystick;
  36465. /**
  36466. * Gets the left stick of the virtual joystick.
  36467. * @returns The virtual Joystick
  36468. */
  36469. getLeftJoystick(): VirtualJoystick;
  36470. /**
  36471. * Gets the right stick of the virtual joystick.
  36472. * @returns The virtual Joystick
  36473. */
  36474. getRightJoystick(): VirtualJoystick;
  36475. /**
  36476. * Update the current camera state depending on the inputs that have been used this frame.
  36477. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36478. */
  36479. checkInputs(): void;
  36480. /**
  36481. * Attach the input controls to a specific dom element to get the input from.
  36482. * @param element Defines the element the controls should be listened from
  36483. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36484. */
  36485. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36486. /**
  36487. * Detach the current controls from the specified dom element.
  36488. * @param element Defines the element to stop listening the inputs from
  36489. */
  36490. detachControl(element: Nullable<HTMLElement>): void;
  36491. /**
  36492. * Gets the class name of the current intput.
  36493. * @returns the class name
  36494. */
  36495. getClassName(): string;
  36496. /**
  36497. * Get the friendly name associated with the input class.
  36498. * @returns the input friendly name
  36499. */
  36500. getSimpleName(): string;
  36501. }
  36502. }
  36503. declare module BABYLON {
  36504. /**
  36505. * This represents a FPS type of camera controlled by touch.
  36506. * This is like a universal camera minus the Gamepad controls.
  36507. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36508. */
  36509. export class TouchCamera extends FreeCamera {
  36510. /**
  36511. * Defines the touch sensibility for rotation.
  36512. * The higher the faster.
  36513. */
  36514. touchAngularSensibility: number;
  36515. /**
  36516. * Defines the touch sensibility for move.
  36517. * The higher the faster.
  36518. */
  36519. touchMoveSensibility: number;
  36520. /**
  36521. * Instantiates a new touch camera.
  36522. * This represents a FPS type of camera controlled by touch.
  36523. * This is like a universal camera minus the Gamepad controls.
  36524. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36525. * @param name Define the name of the camera in the scene
  36526. * @param position Define the start position of the camera in the scene
  36527. * @param scene Define the scene the camera belongs to
  36528. */
  36529. constructor(name: string, position: Vector3, scene: Scene);
  36530. /**
  36531. * Gets the current object class name.
  36532. * @return the class name
  36533. */
  36534. getClassName(): string;
  36535. /** @hidden */ setupInputs(): void;
  36536. }
  36537. }
  36538. declare module BABYLON {
  36539. /**
  36540. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36541. * being tilted forward or back and left or right.
  36542. */
  36543. export class DeviceOrientationCamera extends FreeCamera {
  36544. private _initialQuaternion;
  36545. private _quaternionCache;
  36546. private _tmpDragQuaternion;
  36547. /**
  36548. * Creates a new device orientation camera
  36549. * @param name The name of the camera
  36550. * @param position The start position camera
  36551. * @param scene The scene the camera belongs to
  36552. */
  36553. constructor(name: string, position: Vector3, scene: Scene);
  36554. /**
  36555. * Disabled pointer input on first orientation sensor update (Default: true)
  36556. */
  36557. disablePointerInputWhenUsingDeviceOrientation: boolean;
  36558. private _dragFactor;
  36559. /**
  36560. * Enabled turning on the y axis when the orientation sensor is active
  36561. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  36562. */
  36563. enableHorizontalDragging(dragFactor?: number): void;
  36564. /**
  36565. * Gets the current instance class name ("DeviceOrientationCamera").
  36566. * This helps avoiding instanceof at run time.
  36567. * @returns the class name
  36568. */
  36569. getClassName(): string;
  36570. /**
  36571. * @hidden
  36572. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36573. */ checkInputs(): void;
  36574. /**
  36575. * Reset the camera to its default orientation on the specified axis only.
  36576. * @param axis The axis to reset
  36577. */
  36578. resetToCurrentRotation(axis?: Axis): void;
  36579. }
  36580. }
  36581. declare module BABYLON {
  36582. /**
  36583. * 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,
  36584. * which still works and will still be found in many Playgrounds.
  36585. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36586. */
  36587. export class UniversalCamera extends TouchCamera {
  36588. /**
  36589. * Defines the gamepad rotation sensiblity.
  36590. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36591. */
  36592. gamepadAngularSensibility: number;
  36593. /**
  36594. * Defines the gamepad move sensiblity.
  36595. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36596. */
  36597. gamepadMoveSensibility: number;
  36598. /**
  36599. * 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,
  36600. * which still works and will still be found in many Playgrounds.
  36601. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36602. * @param name Define the name of the camera in the scene
  36603. * @param position Define the start position of the camera in the scene
  36604. * @param scene Define the scene the camera belongs to
  36605. */
  36606. constructor(name: string, position: Vector3, scene: Scene);
  36607. /**
  36608. * Gets the current object class name.
  36609. * @return the class name
  36610. */
  36611. getClassName(): string;
  36612. }
  36613. }
  36614. declare module BABYLON {
  36615. /**
  36616. * This represents a FPS type of camera. This is only here for back compat purpose.
  36617. * Please use the UniversalCamera instead as both are identical.
  36618. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36619. */
  36620. export class GamepadCamera extends UniversalCamera {
  36621. /**
  36622. * Instantiates a new Gamepad Camera
  36623. * This represents a FPS type of camera. This is only here for back compat purpose.
  36624. * Please use the UniversalCamera instead as both are identical.
  36625. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36626. * @param name Define the name of the camera in the scene
  36627. * @param position Define the start position of the camera in the scene
  36628. * @param scene Define the scene the camera belongs to
  36629. */
  36630. constructor(name: string, position: Vector3, scene: Scene);
  36631. /**
  36632. * Gets the current object class name.
  36633. * @return the class name
  36634. */
  36635. getClassName(): string;
  36636. }
  36637. }
  36638. declare module BABYLON {
  36639. /** @hidden */
  36640. export var passPixelShader: {
  36641. name: string;
  36642. shader: string;
  36643. };
  36644. }
  36645. declare module BABYLON {
  36646. /** @hidden */
  36647. export var passCubePixelShader: {
  36648. name: string;
  36649. shader: string;
  36650. };
  36651. }
  36652. declare module BABYLON {
  36653. /**
  36654. * PassPostProcess which produces an output the same as it's input
  36655. */
  36656. export class PassPostProcess extends PostProcess {
  36657. /**
  36658. * Creates the PassPostProcess
  36659. * @param name The name of the effect.
  36660. * @param options The required width/height ratio to downsize to before computing the render pass.
  36661. * @param camera The camera to apply the render pass to.
  36662. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36663. * @param engine The engine which the post process will be applied. (default: current engine)
  36664. * @param reusable If the post process can be reused on the same frame. (default: false)
  36665. * @param textureType The type of texture to be used when performing the post processing.
  36666. * @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)
  36667. */
  36668. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36669. }
  36670. /**
  36671. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36672. */
  36673. export class PassCubePostProcess extends PostProcess {
  36674. private _face;
  36675. /**
  36676. * Gets or sets the cube face to display.
  36677. * * 0 is +X
  36678. * * 1 is -X
  36679. * * 2 is +Y
  36680. * * 3 is -Y
  36681. * * 4 is +Z
  36682. * * 5 is -Z
  36683. */
  36684. face: number;
  36685. /**
  36686. * Creates the PassCubePostProcess
  36687. * @param name The name of the effect.
  36688. * @param options The required width/height ratio to downsize to before computing the render pass.
  36689. * @param camera The camera to apply the render pass to.
  36690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36691. * @param engine The engine which the post process will be applied. (default: current engine)
  36692. * @param reusable If the post process can be reused on the same frame. (default: false)
  36693. * @param textureType The type of texture to be used when performing the post processing.
  36694. * @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)
  36695. */
  36696. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36697. }
  36698. }
  36699. declare module BABYLON {
  36700. /** @hidden */
  36701. export var anaglyphPixelShader: {
  36702. name: string;
  36703. shader: string;
  36704. };
  36705. }
  36706. declare module BABYLON {
  36707. /**
  36708. * Postprocess used to generate anaglyphic rendering
  36709. */
  36710. export class AnaglyphPostProcess extends PostProcess {
  36711. private _passedProcess;
  36712. /**
  36713. * Creates a new AnaglyphPostProcess
  36714. * @param name defines postprocess name
  36715. * @param options defines creation options or target ratio scale
  36716. * @param rigCameras defines cameras using this postprocess
  36717. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  36718. * @param engine defines hosting engine
  36719. * @param reusable defines if the postprocess will be reused multiple times per frame
  36720. */
  36721. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  36722. }
  36723. }
  36724. declare module BABYLON {
  36725. /**
  36726. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  36727. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36728. */
  36729. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  36730. /**
  36731. * Creates a new AnaglyphArcRotateCamera
  36732. * @param name defines camera name
  36733. * @param alpha defines alpha angle (in radians)
  36734. * @param beta defines beta angle (in radians)
  36735. * @param radius defines radius
  36736. * @param target defines camera target
  36737. * @param interaxialDistance defines distance between each color axis
  36738. * @param scene defines the hosting scene
  36739. */
  36740. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  36741. /**
  36742. * Gets camera class name
  36743. * @returns AnaglyphArcRotateCamera
  36744. */
  36745. getClassName(): string;
  36746. }
  36747. }
  36748. declare module BABYLON {
  36749. /**
  36750. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  36751. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36752. */
  36753. export class AnaglyphFreeCamera extends FreeCamera {
  36754. /**
  36755. * Creates a new AnaglyphFreeCamera
  36756. * @param name defines camera name
  36757. * @param position defines initial position
  36758. * @param interaxialDistance defines distance between each color axis
  36759. * @param scene defines the hosting scene
  36760. */
  36761. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36762. /**
  36763. * Gets camera class name
  36764. * @returns AnaglyphFreeCamera
  36765. */
  36766. getClassName(): string;
  36767. }
  36768. }
  36769. declare module BABYLON {
  36770. /**
  36771. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  36772. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36773. */
  36774. export class AnaglyphGamepadCamera extends GamepadCamera {
  36775. /**
  36776. * Creates a new AnaglyphGamepadCamera
  36777. * @param name defines camera name
  36778. * @param position defines initial position
  36779. * @param interaxialDistance defines distance between each color axis
  36780. * @param scene defines the hosting scene
  36781. */
  36782. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36783. /**
  36784. * Gets camera class name
  36785. * @returns AnaglyphGamepadCamera
  36786. */
  36787. getClassName(): string;
  36788. }
  36789. }
  36790. declare module BABYLON {
  36791. /**
  36792. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  36793. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36794. */
  36795. export class AnaglyphUniversalCamera extends UniversalCamera {
  36796. /**
  36797. * Creates a new AnaglyphUniversalCamera
  36798. * @param name defines camera name
  36799. * @param position defines initial position
  36800. * @param interaxialDistance defines distance between each color axis
  36801. * @param scene defines the hosting scene
  36802. */
  36803. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36804. /**
  36805. * Gets camera class name
  36806. * @returns AnaglyphUniversalCamera
  36807. */
  36808. getClassName(): string;
  36809. }
  36810. }
  36811. declare module BABYLON {
  36812. /** @hidden */
  36813. export var stereoscopicInterlacePixelShader: {
  36814. name: string;
  36815. shader: string;
  36816. };
  36817. }
  36818. declare module BABYLON {
  36819. /**
  36820. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  36821. */
  36822. export class StereoscopicInterlacePostProcess extends PostProcess {
  36823. private _stepSize;
  36824. private _passedProcess;
  36825. /**
  36826. * Initializes a StereoscopicInterlacePostProcess
  36827. * @param name The name of the effect.
  36828. * @param rigCameras The rig cameras to be appled to the post process
  36829. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  36830. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36831. * @param engine The engine which the post process will be applied. (default: current engine)
  36832. * @param reusable If the post process can be reused on the same frame. (default: false)
  36833. */
  36834. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36835. }
  36836. }
  36837. declare module BABYLON {
  36838. /**
  36839. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  36840. * @see http://doc.babylonjs.com/features/cameras
  36841. */
  36842. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  36843. /**
  36844. * Creates a new StereoscopicArcRotateCamera
  36845. * @param name defines camera name
  36846. * @param alpha defines alpha angle (in radians)
  36847. * @param beta defines beta angle (in radians)
  36848. * @param radius defines radius
  36849. * @param target defines camera target
  36850. * @param interaxialDistance defines distance between each color axis
  36851. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36852. * @param scene defines the hosting scene
  36853. */
  36854. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36855. /**
  36856. * Gets camera class name
  36857. * @returns StereoscopicArcRotateCamera
  36858. */
  36859. getClassName(): string;
  36860. }
  36861. }
  36862. declare module BABYLON {
  36863. /**
  36864. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  36865. * @see http://doc.babylonjs.com/features/cameras
  36866. */
  36867. export class StereoscopicFreeCamera extends FreeCamera {
  36868. /**
  36869. * Creates a new StereoscopicFreeCamera
  36870. * @param name defines camera name
  36871. * @param position defines initial position
  36872. * @param interaxialDistance defines distance between each color axis
  36873. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36874. * @param scene defines the hosting scene
  36875. */
  36876. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36877. /**
  36878. * Gets camera class name
  36879. * @returns StereoscopicFreeCamera
  36880. */
  36881. getClassName(): string;
  36882. }
  36883. }
  36884. declare module BABYLON {
  36885. /**
  36886. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  36887. * @see http://doc.babylonjs.com/features/cameras
  36888. */
  36889. export class StereoscopicGamepadCamera extends GamepadCamera {
  36890. /**
  36891. * Creates a new StereoscopicGamepadCamera
  36892. * @param name defines camera name
  36893. * @param position defines initial position
  36894. * @param interaxialDistance defines distance between each color axis
  36895. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36896. * @param scene defines the hosting scene
  36897. */
  36898. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36899. /**
  36900. * Gets camera class name
  36901. * @returns StereoscopicGamepadCamera
  36902. */
  36903. getClassName(): string;
  36904. }
  36905. }
  36906. declare module BABYLON {
  36907. /**
  36908. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  36909. * @see http://doc.babylonjs.com/features/cameras
  36910. */
  36911. export class StereoscopicUniversalCamera extends UniversalCamera {
  36912. /**
  36913. * Creates a new StereoscopicUniversalCamera
  36914. * @param name defines camera name
  36915. * @param position defines initial position
  36916. * @param interaxialDistance defines distance between each color axis
  36917. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36918. * @param scene defines the hosting scene
  36919. */
  36920. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36921. /**
  36922. * Gets camera class name
  36923. * @returns StereoscopicUniversalCamera
  36924. */
  36925. getClassName(): string;
  36926. }
  36927. }
  36928. declare module BABYLON {
  36929. /**
  36930. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  36931. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  36932. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  36933. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  36934. */
  36935. export class VirtualJoysticksCamera extends FreeCamera {
  36936. /**
  36937. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  36938. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  36939. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  36940. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  36941. * @param name Define the name of the camera in the scene
  36942. * @param position Define the start position of the camera in the scene
  36943. * @param scene Define the scene the camera belongs to
  36944. */
  36945. constructor(name: string, position: Vector3, scene: Scene);
  36946. /**
  36947. * Gets the current object class name.
  36948. * @return the class name
  36949. */
  36950. getClassName(): string;
  36951. }
  36952. }
  36953. declare module BABYLON {
  36954. /**
  36955. * This represents all the required metrics to create a VR camera.
  36956. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  36957. */
  36958. export class VRCameraMetrics {
  36959. /**
  36960. * Define the horizontal resolution off the screen.
  36961. */
  36962. hResolution: number;
  36963. /**
  36964. * Define the vertical resolution off the screen.
  36965. */
  36966. vResolution: number;
  36967. /**
  36968. * Define the horizontal screen size.
  36969. */
  36970. hScreenSize: number;
  36971. /**
  36972. * Define the vertical screen size.
  36973. */
  36974. vScreenSize: number;
  36975. /**
  36976. * Define the vertical screen center position.
  36977. */
  36978. vScreenCenter: number;
  36979. /**
  36980. * Define the distance of the eyes to the screen.
  36981. */
  36982. eyeToScreenDistance: number;
  36983. /**
  36984. * Define the distance between both lenses
  36985. */
  36986. lensSeparationDistance: number;
  36987. /**
  36988. * Define the distance between both viewer's eyes.
  36989. */
  36990. interpupillaryDistance: number;
  36991. /**
  36992. * Define the distortion factor of the VR postprocess.
  36993. * Please, touch with care.
  36994. */
  36995. distortionK: number[];
  36996. /**
  36997. * Define the chromatic aberration correction factors for the VR post process.
  36998. */
  36999. chromaAbCorrection: number[];
  37000. /**
  37001. * Define the scale factor of the post process.
  37002. * The smaller the better but the slower.
  37003. */
  37004. postProcessScaleFactor: number;
  37005. /**
  37006. * Define an offset for the lens center.
  37007. */
  37008. lensCenterOffset: number;
  37009. /**
  37010. * Define if the current vr camera should compensate the distortion of the lense or not.
  37011. */
  37012. compensateDistortion: boolean;
  37013. /**
  37014. * Defines if multiview should be enabled when rendering (Default: false)
  37015. */
  37016. multiviewEnabled: boolean;
  37017. /**
  37018. * Gets the rendering aspect ratio based on the provided resolutions.
  37019. */
  37020. readonly aspectRatio: number;
  37021. /**
  37022. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37023. */
  37024. readonly aspectRatioFov: number;
  37025. /**
  37026. * @hidden
  37027. */
  37028. readonly leftHMatrix: Matrix;
  37029. /**
  37030. * @hidden
  37031. */
  37032. readonly rightHMatrix: Matrix;
  37033. /**
  37034. * @hidden
  37035. */
  37036. readonly leftPreViewMatrix: Matrix;
  37037. /**
  37038. * @hidden
  37039. */
  37040. readonly rightPreViewMatrix: Matrix;
  37041. /**
  37042. * Get the default VRMetrics based on the most generic setup.
  37043. * @returns the default vr metrics
  37044. */
  37045. static GetDefault(): VRCameraMetrics;
  37046. }
  37047. }
  37048. declare module BABYLON {
  37049. /** @hidden */
  37050. export var vrDistortionCorrectionPixelShader: {
  37051. name: string;
  37052. shader: string;
  37053. };
  37054. }
  37055. declare module BABYLON {
  37056. /**
  37057. * VRDistortionCorrectionPostProcess used for mobile VR
  37058. */
  37059. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37060. private _isRightEye;
  37061. private _distortionFactors;
  37062. private _postProcessScaleFactor;
  37063. private _lensCenterOffset;
  37064. private _scaleIn;
  37065. private _scaleFactor;
  37066. private _lensCenter;
  37067. /**
  37068. * Initializes the VRDistortionCorrectionPostProcess
  37069. * @param name The name of the effect.
  37070. * @param camera The camera to apply the render pass to.
  37071. * @param isRightEye If this is for the right eye distortion
  37072. * @param vrMetrics All the required metrics for the VR camera
  37073. */
  37074. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37075. }
  37076. }
  37077. declare module BABYLON {
  37078. /**
  37079. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37080. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37081. */
  37082. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37083. /**
  37084. * Creates a new VRDeviceOrientationArcRotateCamera
  37085. * @param name defines camera name
  37086. * @param alpha defines the camera rotation along the logitudinal axis
  37087. * @param beta defines the camera rotation along the latitudinal axis
  37088. * @param radius defines the camera distance from its target
  37089. * @param target defines the camera target
  37090. * @param scene defines the scene the camera belongs to
  37091. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37092. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37093. */
  37094. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37095. /**
  37096. * Gets camera class name
  37097. * @returns VRDeviceOrientationArcRotateCamera
  37098. */
  37099. getClassName(): string;
  37100. }
  37101. }
  37102. declare module BABYLON {
  37103. /**
  37104. * Camera used to simulate VR rendering (based on FreeCamera)
  37105. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37106. */
  37107. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37108. /**
  37109. * Creates a new VRDeviceOrientationFreeCamera
  37110. * @param name defines camera name
  37111. * @param position defines the start position of the camera
  37112. * @param scene defines the scene the camera belongs to
  37113. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37114. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37115. */
  37116. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37117. /**
  37118. * Gets camera class name
  37119. * @returns VRDeviceOrientationFreeCamera
  37120. */
  37121. getClassName(): string;
  37122. }
  37123. }
  37124. declare module BABYLON {
  37125. /**
  37126. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37127. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37128. */
  37129. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37130. /**
  37131. * Creates a new VRDeviceOrientationGamepadCamera
  37132. * @param name defines camera name
  37133. * @param position defines the start position of the camera
  37134. * @param scene defines the scene the camera belongs to
  37135. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37136. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37137. */
  37138. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37139. /**
  37140. * Gets camera class name
  37141. * @returns VRDeviceOrientationGamepadCamera
  37142. */
  37143. getClassName(): string;
  37144. }
  37145. }
  37146. declare module BABYLON {
  37147. /**
  37148. * Defines supported buttons for XBox360 compatible gamepads
  37149. */
  37150. export enum Xbox360Button {
  37151. /** A */
  37152. A = 0,
  37153. /** B */
  37154. B = 1,
  37155. /** X */
  37156. X = 2,
  37157. /** Y */
  37158. Y = 3,
  37159. /** Start */
  37160. Start = 4,
  37161. /** Back */
  37162. Back = 5,
  37163. /** Left button */
  37164. LB = 6,
  37165. /** Right button */
  37166. RB = 7,
  37167. /** Left stick */
  37168. LeftStick = 8,
  37169. /** Right stick */
  37170. RightStick = 9
  37171. }
  37172. /** Defines values for XBox360 DPad */
  37173. export enum Xbox360Dpad {
  37174. /** Up */
  37175. Up = 0,
  37176. /** Down */
  37177. Down = 1,
  37178. /** Left */
  37179. Left = 2,
  37180. /** Right */
  37181. Right = 3
  37182. }
  37183. /**
  37184. * Defines a XBox360 gamepad
  37185. */
  37186. export class Xbox360Pad extends Gamepad {
  37187. private _leftTrigger;
  37188. private _rightTrigger;
  37189. private _onlefttriggerchanged;
  37190. private _onrighttriggerchanged;
  37191. private _onbuttondown;
  37192. private _onbuttonup;
  37193. private _ondpaddown;
  37194. private _ondpadup;
  37195. /** Observable raised when a button is pressed */
  37196. onButtonDownObservable: Observable<Xbox360Button>;
  37197. /** Observable raised when a button is released */
  37198. onButtonUpObservable: Observable<Xbox360Button>;
  37199. /** Observable raised when a pad is pressed */
  37200. onPadDownObservable: Observable<Xbox360Dpad>;
  37201. /** Observable raised when a pad is released */
  37202. onPadUpObservable: Observable<Xbox360Dpad>;
  37203. private _buttonA;
  37204. private _buttonB;
  37205. private _buttonX;
  37206. private _buttonY;
  37207. private _buttonBack;
  37208. private _buttonStart;
  37209. private _buttonLB;
  37210. private _buttonRB;
  37211. private _buttonLeftStick;
  37212. private _buttonRightStick;
  37213. private _dPadUp;
  37214. private _dPadDown;
  37215. private _dPadLeft;
  37216. private _dPadRight;
  37217. private _isXboxOnePad;
  37218. /**
  37219. * Creates a new XBox360 gamepad object
  37220. * @param id defines the id of this gamepad
  37221. * @param index defines its index
  37222. * @param gamepad defines the internal HTML gamepad object
  37223. * @param xboxOne defines if it is a XBox One gamepad
  37224. */
  37225. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37226. /**
  37227. * Defines the callback to call when left trigger is pressed
  37228. * @param callback defines the callback to use
  37229. */
  37230. onlefttriggerchanged(callback: (value: number) => void): void;
  37231. /**
  37232. * Defines the callback to call when right trigger is pressed
  37233. * @param callback defines the callback to use
  37234. */
  37235. onrighttriggerchanged(callback: (value: number) => void): void;
  37236. /**
  37237. * Gets the left trigger value
  37238. */
  37239. /**
  37240. * Sets the left trigger value
  37241. */
  37242. leftTrigger: number;
  37243. /**
  37244. * Gets the right trigger value
  37245. */
  37246. /**
  37247. * Sets the right trigger value
  37248. */
  37249. rightTrigger: number;
  37250. /**
  37251. * Defines the callback to call when a button is pressed
  37252. * @param callback defines the callback to use
  37253. */
  37254. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37255. /**
  37256. * Defines the callback to call when a button is released
  37257. * @param callback defines the callback to use
  37258. */
  37259. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37260. /**
  37261. * Defines the callback to call when a pad is pressed
  37262. * @param callback defines the callback to use
  37263. */
  37264. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37265. /**
  37266. * Defines the callback to call when a pad is released
  37267. * @param callback defines the callback to use
  37268. */
  37269. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37270. private _setButtonValue;
  37271. private _setDPadValue;
  37272. /**
  37273. * Gets the value of the `A` button
  37274. */
  37275. /**
  37276. * Sets the value of the `A` button
  37277. */
  37278. buttonA: number;
  37279. /**
  37280. * Gets the value of the `B` button
  37281. */
  37282. /**
  37283. * Sets the value of the `B` button
  37284. */
  37285. buttonB: number;
  37286. /**
  37287. * Gets the value of the `X` button
  37288. */
  37289. /**
  37290. * Sets the value of the `X` button
  37291. */
  37292. buttonX: number;
  37293. /**
  37294. * Gets the value of the `Y` button
  37295. */
  37296. /**
  37297. * Sets the value of the `Y` button
  37298. */
  37299. buttonY: number;
  37300. /**
  37301. * Gets the value of the `Start` button
  37302. */
  37303. /**
  37304. * Sets the value of the `Start` button
  37305. */
  37306. buttonStart: number;
  37307. /**
  37308. * Gets the value of the `Back` button
  37309. */
  37310. /**
  37311. * Sets the value of the `Back` button
  37312. */
  37313. buttonBack: number;
  37314. /**
  37315. * Gets the value of the `Left` button
  37316. */
  37317. /**
  37318. * Sets the value of the `Left` button
  37319. */
  37320. buttonLB: number;
  37321. /**
  37322. * Gets the value of the `Right` button
  37323. */
  37324. /**
  37325. * Sets the value of the `Right` button
  37326. */
  37327. buttonRB: number;
  37328. /**
  37329. * Gets the value of the Left joystick
  37330. */
  37331. /**
  37332. * Sets the value of the Left joystick
  37333. */
  37334. buttonLeftStick: number;
  37335. /**
  37336. * Gets the value of the Right joystick
  37337. */
  37338. /**
  37339. * Sets the value of the Right joystick
  37340. */
  37341. buttonRightStick: number;
  37342. /**
  37343. * Gets the value of D-pad up
  37344. */
  37345. /**
  37346. * Sets the value of D-pad up
  37347. */
  37348. dPadUp: number;
  37349. /**
  37350. * Gets the value of D-pad down
  37351. */
  37352. /**
  37353. * Sets the value of D-pad down
  37354. */
  37355. dPadDown: number;
  37356. /**
  37357. * Gets the value of D-pad left
  37358. */
  37359. /**
  37360. * Sets the value of D-pad left
  37361. */
  37362. dPadLeft: number;
  37363. /**
  37364. * Gets the value of D-pad right
  37365. */
  37366. /**
  37367. * Sets the value of D-pad right
  37368. */
  37369. dPadRight: number;
  37370. /**
  37371. * Force the gamepad to synchronize with device values
  37372. */
  37373. update(): void;
  37374. /**
  37375. * Disposes the gamepad
  37376. */
  37377. dispose(): void;
  37378. }
  37379. }
  37380. declare module BABYLON {
  37381. /**
  37382. * Base class of materials working in push mode in babylon JS
  37383. * @hidden
  37384. */
  37385. export class PushMaterial extends Material {
  37386. protected _activeEffect: Effect;
  37387. protected _normalMatrix: Matrix;
  37388. /**
  37389. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  37390. * This means that the material can keep using a previous shader while a new one is being compiled.
  37391. * This is mostly used when shader parallel compilation is supported (true by default)
  37392. */
  37393. allowShaderHotSwapping: boolean;
  37394. constructor(name: string, scene: Scene);
  37395. getEffect(): Effect;
  37396. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  37397. /**
  37398. * Binds the given world matrix to the active effect
  37399. *
  37400. * @param world the matrix to bind
  37401. */
  37402. bindOnlyWorldMatrix(world: Matrix): void;
  37403. /**
  37404. * Binds the given normal matrix to the active effect
  37405. *
  37406. * @param normalMatrix the matrix to bind
  37407. */
  37408. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  37409. bind(world: Matrix, mesh?: Mesh): void;
  37410. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  37411. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  37412. }
  37413. }
  37414. declare module BABYLON {
  37415. /**
  37416. * This groups all the flags used to control the materials channel.
  37417. */
  37418. export class MaterialFlags {
  37419. private static _DiffuseTextureEnabled;
  37420. /**
  37421. * Are diffuse textures enabled in the application.
  37422. */
  37423. static DiffuseTextureEnabled: boolean;
  37424. private static _AmbientTextureEnabled;
  37425. /**
  37426. * Are ambient textures enabled in the application.
  37427. */
  37428. static AmbientTextureEnabled: boolean;
  37429. private static _OpacityTextureEnabled;
  37430. /**
  37431. * Are opacity textures enabled in the application.
  37432. */
  37433. static OpacityTextureEnabled: boolean;
  37434. private static _ReflectionTextureEnabled;
  37435. /**
  37436. * Are reflection textures enabled in the application.
  37437. */
  37438. static ReflectionTextureEnabled: boolean;
  37439. private static _EmissiveTextureEnabled;
  37440. /**
  37441. * Are emissive textures enabled in the application.
  37442. */
  37443. static EmissiveTextureEnabled: boolean;
  37444. private static _SpecularTextureEnabled;
  37445. /**
  37446. * Are specular textures enabled in the application.
  37447. */
  37448. static SpecularTextureEnabled: boolean;
  37449. private static _BumpTextureEnabled;
  37450. /**
  37451. * Are bump textures enabled in the application.
  37452. */
  37453. static BumpTextureEnabled: boolean;
  37454. private static _LightmapTextureEnabled;
  37455. /**
  37456. * Are lightmap textures enabled in the application.
  37457. */
  37458. static LightmapTextureEnabled: boolean;
  37459. private static _RefractionTextureEnabled;
  37460. /**
  37461. * Are refraction textures enabled in the application.
  37462. */
  37463. static RefractionTextureEnabled: boolean;
  37464. private static _ColorGradingTextureEnabled;
  37465. /**
  37466. * Are color grading textures enabled in the application.
  37467. */
  37468. static ColorGradingTextureEnabled: boolean;
  37469. private static _FresnelEnabled;
  37470. /**
  37471. * Are fresnels enabled in the application.
  37472. */
  37473. static FresnelEnabled: boolean;
  37474. private static _ClearCoatTextureEnabled;
  37475. /**
  37476. * Are clear coat textures enabled in the application.
  37477. */
  37478. static ClearCoatTextureEnabled: boolean;
  37479. private static _ClearCoatBumpTextureEnabled;
  37480. /**
  37481. * Are clear coat bump textures enabled in the application.
  37482. */
  37483. static ClearCoatBumpTextureEnabled: boolean;
  37484. private static _ClearCoatTintTextureEnabled;
  37485. /**
  37486. * Are clear coat tint textures enabled in the application.
  37487. */
  37488. static ClearCoatTintTextureEnabled: boolean;
  37489. private static _SheenTextureEnabled;
  37490. /**
  37491. * Are sheen textures enabled in the application.
  37492. */
  37493. static SheenTextureEnabled: boolean;
  37494. private static _AnisotropicTextureEnabled;
  37495. /**
  37496. * Are anisotropic textures enabled in the application.
  37497. */
  37498. static AnisotropicTextureEnabled: boolean;
  37499. private static _ThicknessTextureEnabled;
  37500. /**
  37501. * Are thickness textures enabled in the application.
  37502. */
  37503. static ThicknessTextureEnabled: boolean;
  37504. }
  37505. }
  37506. declare module BABYLON {
  37507. /** @hidden */
  37508. export var defaultFragmentDeclaration: {
  37509. name: string;
  37510. shader: string;
  37511. };
  37512. }
  37513. declare module BABYLON {
  37514. /** @hidden */
  37515. export var defaultUboDeclaration: {
  37516. name: string;
  37517. shader: string;
  37518. };
  37519. }
  37520. declare module BABYLON {
  37521. /** @hidden */
  37522. export var lightFragmentDeclaration: {
  37523. name: string;
  37524. shader: string;
  37525. };
  37526. }
  37527. declare module BABYLON {
  37528. /** @hidden */
  37529. export var lightUboDeclaration: {
  37530. name: string;
  37531. shader: string;
  37532. };
  37533. }
  37534. declare module BABYLON {
  37535. /** @hidden */
  37536. export var lightsFragmentFunctions: {
  37537. name: string;
  37538. shader: string;
  37539. };
  37540. }
  37541. declare module BABYLON {
  37542. /** @hidden */
  37543. export var shadowsFragmentFunctions: {
  37544. name: string;
  37545. shader: string;
  37546. };
  37547. }
  37548. declare module BABYLON {
  37549. /** @hidden */
  37550. export var fresnelFunction: {
  37551. name: string;
  37552. shader: string;
  37553. };
  37554. }
  37555. declare module BABYLON {
  37556. /** @hidden */
  37557. export var reflectionFunction: {
  37558. name: string;
  37559. shader: string;
  37560. };
  37561. }
  37562. declare module BABYLON {
  37563. /** @hidden */
  37564. export var bumpFragmentFunctions: {
  37565. name: string;
  37566. shader: string;
  37567. };
  37568. }
  37569. declare module BABYLON {
  37570. /** @hidden */
  37571. export var logDepthDeclaration: {
  37572. name: string;
  37573. shader: string;
  37574. };
  37575. }
  37576. declare module BABYLON {
  37577. /** @hidden */
  37578. export var bumpFragment: {
  37579. name: string;
  37580. shader: string;
  37581. };
  37582. }
  37583. declare module BABYLON {
  37584. /** @hidden */
  37585. export var depthPrePass: {
  37586. name: string;
  37587. shader: string;
  37588. };
  37589. }
  37590. declare module BABYLON {
  37591. /** @hidden */
  37592. export var lightFragment: {
  37593. name: string;
  37594. shader: string;
  37595. };
  37596. }
  37597. declare module BABYLON {
  37598. /** @hidden */
  37599. export var logDepthFragment: {
  37600. name: string;
  37601. shader: string;
  37602. };
  37603. }
  37604. declare module BABYLON {
  37605. /** @hidden */
  37606. export var defaultPixelShader: {
  37607. name: string;
  37608. shader: string;
  37609. };
  37610. }
  37611. declare module BABYLON {
  37612. /** @hidden */
  37613. export var defaultVertexDeclaration: {
  37614. name: string;
  37615. shader: string;
  37616. };
  37617. }
  37618. declare module BABYLON {
  37619. /** @hidden */
  37620. export var bumpVertexDeclaration: {
  37621. name: string;
  37622. shader: string;
  37623. };
  37624. }
  37625. declare module BABYLON {
  37626. /** @hidden */
  37627. export var bumpVertex: {
  37628. name: string;
  37629. shader: string;
  37630. };
  37631. }
  37632. declare module BABYLON {
  37633. /** @hidden */
  37634. export var fogVertex: {
  37635. name: string;
  37636. shader: string;
  37637. };
  37638. }
  37639. declare module BABYLON {
  37640. /** @hidden */
  37641. export var shadowsVertex: {
  37642. name: string;
  37643. shader: string;
  37644. };
  37645. }
  37646. declare module BABYLON {
  37647. /** @hidden */
  37648. export var pointCloudVertex: {
  37649. name: string;
  37650. shader: string;
  37651. };
  37652. }
  37653. declare module BABYLON {
  37654. /** @hidden */
  37655. export var logDepthVertex: {
  37656. name: string;
  37657. shader: string;
  37658. };
  37659. }
  37660. declare module BABYLON {
  37661. /** @hidden */
  37662. export var defaultVertexShader: {
  37663. name: string;
  37664. shader: string;
  37665. };
  37666. }
  37667. declare module BABYLON {
  37668. /** @hidden */
  37669. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  37670. MAINUV1: boolean;
  37671. MAINUV2: boolean;
  37672. DIFFUSE: boolean;
  37673. DIFFUSEDIRECTUV: number;
  37674. AMBIENT: boolean;
  37675. AMBIENTDIRECTUV: number;
  37676. OPACITY: boolean;
  37677. OPACITYDIRECTUV: number;
  37678. OPACITYRGB: boolean;
  37679. REFLECTION: boolean;
  37680. EMISSIVE: boolean;
  37681. EMISSIVEDIRECTUV: number;
  37682. SPECULAR: boolean;
  37683. SPECULARDIRECTUV: number;
  37684. BUMP: boolean;
  37685. BUMPDIRECTUV: number;
  37686. PARALLAX: boolean;
  37687. PARALLAXOCCLUSION: boolean;
  37688. SPECULAROVERALPHA: boolean;
  37689. CLIPPLANE: boolean;
  37690. CLIPPLANE2: boolean;
  37691. CLIPPLANE3: boolean;
  37692. CLIPPLANE4: boolean;
  37693. ALPHATEST: boolean;
  37694. DEPTHPREPASS: boolean;
  37695. ALPHAFROMDIFFUSE: boolean;
  37696. POINTSIZE: boolean;
  37697. FOG: boolean;
  37698. SPECULARTERM: boolean;
  37699. DIFFUSEFRESNEL: boolean;
  37700. OPACITYFRESNEL: boolean;
  37701. REFLECTIONFRESNEL: boolean;
  37702. REFRACTIONFRESNEL: boolean;
  37703. EMISSIVEFRESNEL: boolean;
  37704. FRESNEL: boolean;
  37705. NORMAL: boolean;
  37706. UV1: boolean;
  37707. UV2: boolean;
  37708. VERTEXCOLOR: boolean;
  37709. VERTEXALPHA: boolean;
  37710. NUM_BONE_INFLUENCERS: number;
  37711. BonesPerMesh: number;
  37712. BONETEXTURE: boolean;
  37713. INSTANCES: boolean;
  37714. GLOSSINESS: boolean;
  37715. ROUGHNESS: boolean;
  37716. EMISSIVEASILLUMINATION: boolean;
  37717. LINKEMISSIVEWITHDIFFUSE: boolean;
  37718. REFLECTIONFRESNELFROMSPECULAR: boolean;
  37719. LIGHTMAP: boolean;
  37720. LIGHTMAPDIRECTUV: number;
  37721. OBJECTSPACE_NORMALMAP: boolean;
  37722. USELIGHTMAPASSHADOWMAP: boolean;
  37723. REFLECTIONMAP_3D: boolean;
  37724. REFLECTIONMAP_SPHERICAL: boolean;
  37725. REFLECTIONMAP_PLANAR: boolean;
  37726. REFLECTIONMAP_CUBIC: boolean;
  37727. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  37728. REFLECTIONMAP_PROJECTION: boolean;
  37729. REFLECTIONMAP_SKYBOX: boolean;
  37730. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  37731. REFLECTIONMAP_EXPLICIT: boolean;
  37732. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  37733. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  37734. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  37735. INVERTCUBICMAP: boolean;
  37736. LOGARITHMICDEPTH: boolean;
  37737. REFRACTION: boolean;
  37738. REFRACTIONMAP_3D: boolean;
  37739. REFLECTIONOVERALPHA: boolean;
  37740. TWOSIDEDLIGHTING: boolean;
  37741. SHADOWFLOAT: boolean;
  37742. MORPHTARGETS: boolean;
  37743. MORPHTARGETS_NORMAL: boolean;
  37744. MORPHTARGETS_TANGENT: boolean;
  37745. NUM_MORPH_INFLUENCERS: number;
  37746. NONUNIFORMSCALING: boolean;
  37747. PREMULTIPLYALPHA: boolean;
  37748. IMAGEPROCESSING: boolean;
  37749. VIGNETTE: boolean;
  37750. VIGNETTEBLENDMODEMULTIPLY: boolean;
  37751. VIGNETTEBLENDMODEOPAQUE: boolean;
  37752. TONEMAPPING: boolean;
  37753. TONEMAPPING_ACES: boolean;
  37754. CONTRAST: boolean;
  37755. COLORCURVES: boolean;
  37756. COLORGRADING: boolean;
  37757. COLORGRADING3D: boolean;
  37758. SAMPLER3DGREENDEPTH: boolean;
  37759. SAMPLER3DBGRMAP: boolean;
  37760. IMAGEPROCESSINGPOSTPROCESS: boolean;
  37761. MULTIVIEW: boolean;
  37762. /**
  37763. * If the reflection texture on this material is in linear color space
  37764. * @hidden
  37765. */
  37766. IS_REFLECTION_LINEAR: boolean;
  37767. /**
  37768. * If the refraction texture on this material is in linear color space
  37769. * @hidden
  37770. */
  37771. IS_REFRACTION_LINEAR: boolean;
  37772. EXPOSURE: boolean;
  37773. constructor();
  37774. setReflectionMode(modeToEnable: string): void;
  37775. }
  37776. /**
  37777. * This is the default material used in Babylon. It is the best trade off between quality
  37778. * and performances.
  37779. * @see http://doc.babylonjs.com/babylon101/materials
  37780. */
  37781. export class StandardMaterial extends PushMaterial {
  37782. private _diffuseTexture;
  37783. /**
  37784. * The basic texture of the material as viewed under a light.
  37785. */
  37786. diffuseTexture: Nullable<BaseTexture>;
  37787. private _ambientTexture;
  37788. /**
  37789. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  37790. */
  37791. ambientTexture: Nullable<BaseTexture>;
  37792. private _opacityTexture;
  37793. /**
  37794. * Define the transparency of the material from a texture.
  37795. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  37796. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  37797. */
  37798. opacityTexture: Nullable<BaseTexture>;
  37799. private _reflectionTexture;
  37800. /**
  37801. * Define the texture used to display the reflection.
  37802. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37803. */
  37804. reflectionTexture: Nullable<BaseTexture>;
  37805. private _emissiveTexture;
  37806. /**
  37807. * Define texture of the material as if self lit.
  37808. * This will be mixed in the final result even in the absence of light.
  37809. */
  37810. emissiveTexture: Nullable<BaseTexture>;
  37811. private _specularTexture;
  37812. /**
  37813. * Define how the color and intensity of the highlight given by the light in the material.
  37814. */
  37815. specularTexture: Nullable<BaseTexture>;
  37816. private _bumpTexture;
  37817. /**
  37818. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  37819. * 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.
  37820. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  37821. */
  37822. bumpTexture: Nullable<BaseTexture>;
  37823. private _lightmapTexture;
  37824. /**
  37825. * Complex lighting can be computationally expensive to compute at runtime.
  37826. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  37827. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  37828. */
  37829. lightmapTexture: Nullable<BaseTexture>;
  37830. private _refractionTexture;
  37831. /**
  37832. * Define the texture used to display the refraction.
  37833. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37834. */
  37835. refractionTexture: Nullable<BaseTexture>;
  37836. /**
  37837. * The color of the material lit by the environmental background lighting.
  37838. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  37839. */
  37840. ambientColor: Color3;
  37841. /**
  37842. * The basic color of the material as viewed under a light.
  37843. */
  37844. diffuseColor: Color3;
  37845. /**
  37846. * Define how the color and intensity of the highlight given by the light in the material.
  37847. */
  37848. specularColor: Color3;
  37849. /**
  37850. * Define the color of the material as if self lit.
  37851. * This will be mixed in the final result even in the absence of light.
  37852. */
  37853. emissiveColor: Color3;
  37854. /**
  37855. * Defines how sharp are the highlights in the material.
  37856. * The bigger the value the sharper giving a more glossy feeling to the result.
  37857. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  37858. */
  37859. specularPower: number;
  37860. private _useAlphaFromDiffuseTexture;
  37861. /**
  37862. * Does the transparency come from the diffuse texture alpha channel.
  37863. */
  37864. useAlphaFromDiffuseTexture: boolean;
  37865. private _useEmissiveAsIllumination;
  37866. /**
  37867. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  37868. */
  37869. useEmissiveAsIllumination: boolean;
  37870. private _linkEmissiveWithDiffuse;
  37871. /**
  37872. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  37873. * the emissive level when the final color is close to one.
  37874. */
  37875. linkEmissiveWithDiffuse: boolean;
  37876. private _useSpecularOverAlpha;
  37877. /**
  37878. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  37879. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  37880. */
  37881. useSpecularOverAlpha: boolean;
  37882. private _useReflectionOverAlpha;
  37883. /**
  37884. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  37885. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  37886. */
  37887. useReflectionOverAlpha: boolean;
  37888. private _disableLighting;
  37889. /**
  37890. * Does lights from the scene impacts this material.
  37891. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  37892. */
  37893. disableLighting: boolean;
  37894. private _useObjectSpaceNormalMap;
  37895. /**
  37896. * Allows using an object space normal map (instead of tangent space).
  37897. */
  37898. useObjectSpaceNormalMap: boolean;
  37899. private _useParallax;
  37900. /**
  37901. * Is parallax enabled or not.
  37902. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  37903. */
  37904. useParallax: boolean;
  37905. private _useParallaxOcclusion;
  37906. /**
  37907. * Is parallax occlusion enabled or not.
  37908. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  37909. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  37910. */
  37911. useParallaxOcclusion: boolean;
  37912. /**
  37913. * 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.
  37914. */
  37915. parallaxScaleBias: number;
  37916. private _roughness;
  37917. /**
  37918. * Helps to define how blurry the reflections should appears in the material.
  37919. */
  37920. roughness: number;
  37921. /**
  37922. * In case of refraction, define the value of the indice of refraction.
  37923. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37924. */
  37925. indexOfRefraction: number;
  37926. /**
  37927. * Invert the refraction texture alongside the y axis.
  37928. * It can be useful with procedural textures or probe for instance.
  37929. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37930. */
  37931. invertRefractionY: boolean;
  37932. /**
  37933. * Defines the alpha limits in alpha test mode.
  37934. */
  37935. alphaCutOff: number;
  37936. private _useLightmapAsShadowmap;
  37937. /**
  37938. * In case of light mapping, define whether the map contains light or shadow informations.
  37939. */
  37940. useLightmapAsShadowmap: boolean;
  37941. private _diffuseFresnelParameters;
  37942. /**
  37943. * Define the diffuse fresnel parameters of the material.
  37944. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37945. */
  37946. diffuseFresnelParameters: FresnelParameters;
  37947. private _opacityFresnelParameters;
  37948. /**
  37949. * Define the opacity fresnel parameters of the material.
  37950. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37951. */
  37952. opacityFresnelParameters: FresnelParameters;
  37953. private _reflectionFresnelParameters;
  37954. /**
  37955. * Define the reflection fresnel parameters of the material.
  37956. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37957. */
  37958. reflectionFresnelParameters: FresnelParameters;
  37959. private _refractionFresnelParameters;
  37960. /**
  37961. * Define the refraction fresnel parameters of the material.
  37962. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37963. */
  37964. refractionFresnelParameters: FresnelParameters;
  37965. private _emissiveFresnelParameters;
  37966. /**
  37967. * Define the emissive fresnel parameters of the material.
  37968. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37969. */
  37970. emissiveFresnelParameters: FresnelParameters;
  37971. private _useReflectionFresnelFromSpecular;
  37972. /**
  37973. * If true automatically deducts the fresnels values from the material specularity.
  37974. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37975. */
  37976. useReflectionFresnelFromSpecular: boolean;
  37977. private _useGlossinessFromSpecularMapAlpha;
  37978. /**
  37979. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  37980. */
  37981. useGlossinessFromSpecularMapAlpha: boolean;
  37982. private _maxSimultaneousLights;
  37983. /**
  37984. * Defines the maximum number of lights that can be used in the material
  37985. */
  37986. maxSimultaneousLights: number;
  37987. private _invertNormalMapX;
  37988. /**
  37989. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  37990. */
  37991. invertNormalMapX: boolean;
  37992. private _invertNormalMapY;
  37993. /**
  37994. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  37995. */
  37996. invertNormalMapY: boolean;
  37997. private _twoSidedLighting;
  37998. /**
  37999. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38000. */
  38001. twoSidedLighting: boolean;
  38002. /**
  38003. * Default configuration related to image processing available in the standard Material.
  38004. */
  38005. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38006. /**
  38007. * Gets the image processing configuration used either in this material.
  38008. */
  38009. /**
  38010. * Sets the Default image processing configuration used either in the this material.
  38011. *
  38012. * If sets to null, the scene one is in use.
  38013. */
  38014. imageProcessingConfiguration: ImageProcessingConfiguration;
  38015. /**
  38016. * Keep track of the image processing observer to allow dispose and replace.
  38017. */
  38018. private _imageProcessingObserver;
  38019. /**
  38020. * Attaches a new image processing configuration to the Standard Material.
  38021. * @param configuration
  38022. */
  38023. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38024. /**
  38025. * Gets wether the color curves effect is enabled.
  38026. */
  38027. /**
  38028. * Sets wether the color curves effect is enabled.
  38029. */
  38030. cameraColorCurvesEnabled: boolean;
  38031. /**
  38032. * Gets wether the color grading effect is enabled.
  38033. */
  38034. /**
  38035. * Gets wether the color grading effect is enabled.
  38036. */
  38037. cameraColorGradingEnabled: boolean;
  38038. /**
  38039. * Gets wether tonemapping is enabled or not.
  38040. */
  38041. /**
  38042. * Sets wether tonemapping is enabled or not
  38043. */
  38044. cameraToneMappingEnabled: boolean;
  38045. /**
  38046. * The camera exposure used on this material.
  38047. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38048. * This corresponds to a photographic exposure.
  38049. */
  38050. /**
  38051. * The camera exposure used on this material.
  38052. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38053. * This corresponds to a photographic exposure.
  38054. */
  38055. cameraExposure: number;
  38056. /**
  38057. * Gets The camera contrast used on this material.
  38058. */
  38059. /**
  38060. * Sets The camera contrast used on this material.
  38061. */
  38062. cameraContrast: number;
  38063. /**
  38064. * Gets the Color Grading 2D Lookup Texture.
  38065. */
  38066. /**
  38067. * Sets the Color Grading 2D Lookup Texture.
  38068. */
  38069. cameraColorGradingTexture: Nullable<BaseTexture>;
  38070. /**
  38071. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38072. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38073. * 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;
  38074. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38075. */
  38076. /**
  38077. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38078. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38079. * 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;
  38080. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38081. */
  38082. cameraColorCurves: Nullable<ColorCurves>;
  38083. /**
  38084. * Custom callback helping to override the default shader used in the material.
  38085. */
  38086. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38087. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38088. protected _worldViewProjectionMatrix: Matrix;
  38089. protected _globalAmbientColor: Color3;
  38090. protected _useLogarithmicDepth: boolean;
  38091. /**
  38092. * Instantiates a new standard material.
  38093. * This is the default material used in Babylon. It is the best trade off between quality
  38094. * and performances.
  38095. * @see http://doc.babylonjs.com/babylon101/materials
  38096. * @param name Define the name of the material in the scene
  38097. * @param scene Define the scene the material belong to
  38098. */
  38099. constructor(name: string, scene: Scene);
  38100. /**
  38101. * Gets a boolean indicating that current material needs to register RTT
  38102. */
  38103. readonly hasRenderTargetTextures: boolean;
  38104. /**
  38105. * Gets the current class name of the material e.g. "StandardMaterial"
  38106. * Mainly use in serialization.
  38107. * @returns the class name
  38108. */
  38109. getClassName(): string;
  38110. /**
  38111. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38112. * You can try switching to logarithmic depth.
  38113. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38114. */
  38115. useLogarithmicDepth: boolean;
  38116. /**
  38117. * Specifies if the material will require alpha blending
  38118. * @returns a boolean specifying if alpha blending is needed
  38119. */
  38120. needAlphaBlending(): boolean;
  38121. /**
  38122. * Specifies if this material should be rendered in alpha test mode
  38123. * @returns a boolean specifying if an alpha test is needed.
  38124. */
  38125. needAlphaTesting(): boolean;
  38126. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38127. /**
  38128. * Get the texture used for alpha test purpose.
  38129. * @returns the diffuse texture in case of the standard material.
  38130. */
  38131. getAlphaTestTexture(): Nullable<BaseTexture>;
  38132. /**
  38133. * Get if the submesh is ready to be used and all its information available.
  38134. * Child classes can use it to update shaders
  38135. * @param mesh defines the mesh to check
  38136. * @param subMesh defines which submesh to check
  38137. * @param useInstances specifies that instances should be used
  38138. * @returns a boolean indicating that the submesh is ready or not
  38139. */
  38140. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38141. /**
  38142. * Builds the material UBO layouts.
  38143. * Used internally during the effect preparation.
  38144. */
  38145. buildUniformLayout(): void;
  38146. /**
  38147. * Unbinds the material from the mesh
  38148. */
  38149. unbind(): void;
  38150. /**
  38151. * Binds the submesh to this material by preparing the effect and shader to draw
  38152. * @param world defines the world transformation matrix
  38153. * @param mesh defines the mesh containing the submesh
  38154. * @param subMesh defines the submesh to bind the material to
  38155. */
  38156. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38157. /**
  38158. * Get the list of animatables in the material.
  38159. * @returns the list of animatables object used in the material
  38160. */
  38161. getAnimatables(): IAnimatable[];
  38162. /**
  38163. * Gets the active textures from the material
  38164. * @returns an array of textures
  38165. */
  38166. getActiveTextures(): BaseTexture[];
  38167. /**
  38168. * Specifies if the material uses a texture
  38169. * @param texture defines the texture to check against the material
  38170. * @returns a boolean specifying if the material uses the texture
  38171. */
  38172. hasTexture(texture: BaseTexture): boolean;
  38173. /**
  38174. * Disposes the material
  38175. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38176. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38177. */
  38178. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38179. /**
  38180. * Makes a duplicate of the material, and gives it a new name
  38181. * @param name defines the new name for the duplicated material
  38182. * @returns the cloned material
  38183. */
  38184. clone(name: string): StandardMaterial;
  38185. /**
  38186. * Serializes this material in a JSON representation
  38187. * @returns the serialized material object
  38188. */
  38189. serialize(): any;
  38190. /**
  38191. * Creates a standard material from parsed material data
  38192. * @param source defines the JSON representation of the material
  38193. * @param scene defines the hosting scene
  38194. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38195. * @returns a new standard material
  38196. */
  38197. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38198. /**
  38199. * Are diffuse textures enabled in the application.
  38200. */
  38201. static DiffuseTextureEnabled: boolean;
  38202. /**
  38203. * Are ambient textures enabled in the application.
  38204. */
  38205. static AmbientTextureEnabled: boolean;
  38206. /**
  38207. * Are opacity textures enabled in the application.
  38208. */
  38209. static OpacityTextureEnabled: boolean;
  38210. /**
  38211. * Are reflection textures enabled in the application.
  38212. */
  38213. static ReflectionTextureEnabled: boolean;
  38214. /**
  38215. * Are emissive textures enabled in the application.
  38216. */
  38217. static EmissiveTextureEnabled: boolean;
  38218. /**
  38219. * Are specular textures enabled in the application.
  38220. */
  38221. static SpecularTextureEnabled: boolean;
  38222. /**
  38223. * Are bump textures enabled in the application.
  38224. */
  38225. static BumpTextureEnabled: boolean;
  38226. /**
  38227. * Are lightmap textures enabled in the application.
  38228. */
  38229. static LightmapTextureEnabled: boolean;
  38230. /**
  38231. * Are refraction textures enabled in the application.
  38232. */
  38233. static RefractionTextureEnabled: boolean;
  38234. /**
  38235. * Are color grading textures enabled in the application.
  38236. */
  38237. static ColorGradingTextureEnabled: boolean;
  38238. /**
  38239. * Are fresnels enabled in the application.
  38240. */
  38241. static FresnelEnabled: boolean;
  38242. }
  38243. }
  38244. declare module BABYLON {
  38245. /**
  38246. * A class extending Texture allowing drawing on a texture
  38247. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38248. */
  38249. export class DynamicTexture extends Texture {
  38250. private _generateMipMaps;
  38251. private _canvas;
  38252. private _context;
  38253. private _engine;
  38254. /**
  38255. * Creates a DynamicTexture
  38256. * @param name defines the name of the texture
  38257. * @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
  38258. * @param scene defines the scene where you want the texture
  38259. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38260. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38261. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38262. */
  38263. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38264. /**
  38265. * Get the current class name of the texture useful for serialization or dynamic coding.
  38266. * @returns "DynamicTexture"
  38267. */
  38268. getClassName(): string;
  38269. /**
  38270. * Gets the current state of canRescale
  38271. */
  38272. readonly canRescale: boolean;
  38273. private _recreate;
  38274. /**
  38275. * Scales the texture
  38276. * @param ratio the scale factor to apply to both width and height
  38277. */
  38278. scale(ratio: number): void;
  38279. /**
  38280. * Resizes the texture
  38281. * @param width the new width
  38282. * @param height the new height
  38283. */
  38284. scaleTo(width: number, height: number): void;
  38285. /**
  38286. * Gets the context of the canvas used by the texture
  38287. * @returns the canvas context of the dynamic texture
  38288. */
  38289. getContext(): CanvasRenderingContext2D;
  38290. /**
  38291. * Clears the texture
  38292. */
  38293. clear(): void;
  38294. /**
  38295. * Updates the texture
  38296. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38297. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38298. */
  38299. update(invertY?: boolean, premulAlpha?: boolean): void;
  38300. /**
  38301. * Draws text onto the texture
  38302. * @param text defines the text to be drawn
  38303. * @param x defines the placement of the text from the left
  38304. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38305. * @param font defines the font to be used with font-style, font-size, font-name
  38306. * @param color defines the color used for the text
  38307. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38308. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38309. * @param update defines whether texture is immediately update (default is true)
  38310. */
  38311. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38312. /**
  38313. * Clones the texture
  38314. * @returns the clone of the texture.
  38315. */
  38316. clone(): DynamicTexture;
  38317. /**
  38318. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38319. * @returns a serialized dynamic texture object
  38320. */
  38321. serialize(): any;
  38322. /** @hidden */ rebuild(): void;
  38323. }
  38324. }
  38325. declare module BABYLON {
  38326. /** @hidden */
  38327. export var imageProcessingPixelShader: {
  38328. name: string;
  38329. shader: string;
  38330. };
  38331. }
  38332. declare module BABYLON {
  38333. /**
  38334. * ImageProcessingPostProcess
  38335. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  38336. */
  38337. export class ImageProcessingPostProcess extends PostProcess {
  38338. /**
  38339. * Default configuration related to image processing available in the PBR Material.
  38340. */
  38341. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38342. /**
  38343. * Gets the image processing configuration used either in this material.
  38344. */
  38345. /**
  38346. * Sets the Default image processing configuration used either in the this material.
  38347. *
  38348. * If sets to null, the scene one is in use.
  38349. */
  38350. imageProcessingConfiguration: ImageProcessingConfiguration;
  38351. /**
  38352. * Keep track of the image processing observer to allow dispose and replace.
  38353. */
  38354. private _imageProcessingObserver;
  38355. /**
  38356. * Attaches a new image processing configuration to the PBR Material.
  38357. * @param configuration
  38358. */
  38359. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  38360. /**
  38361. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38362. */
  38363. /**
  38364. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38365. */
  38366. colorCurves: Nullable<ColorCurves>;
  38367. /**
  38368. * Gets wether the color curves effect is enabled.
  38369. */
  38370. /**
  38371. * Sets wether the color curves effect is enabled.
  38372. */
  38373. colorCurvesEnabled: boolean;
  38374. /**
  38375. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38376. */
  38377. /**
  38378. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38379. */
  38380. colorGradingTexture: Nullable<BaseTexture>;
  38381. /**
  38382. * Gets wether the color grading effect is enabled.
  38383. */
  38384. /**
  38385. * Gets wether the color grading effect is enabled.
  38386. */
  38387. colorGradingEnabled: boolean;
  38388. /**
  38389. * Gets exposure used in the effect.
  38390. */
  38391. /**
  38392. * Sets exposure used in the effect.
  38393. */
  38394. exposure: number;
  38395. /**
  38396. * Gets wether tonemapping is enabled or not.
  38397. */
  38398. /**
  38399. * Sets wether tonemapping is enabled or not
  38400. */
  38401. toneMappingEnabled: boolean;
  38402. /**
  38403. * Gets the type of tone mapping effect.
  38404. */
  38405. /**
  38406. * Sets the type of tone mapping effect.
  38407. */
  38408. toneMappingType: number;
  38409. /**
  38410. * Gets contrast used in the effect.
  38411. */
  38412. /**
  38413. * Sets contrast used in the effect.
  38414. */
  38415. contrast: number;
  38416. /**
  38417. * Gets Vignette stretch size.
  38418. */
  38419. /**
  38420. * Sets Vignette stretch size.
  38421. */
  38422. vignetteStretch: number;
  38423. /**
  38424. * Gets Vignette centre X Offset.
  38425. */
  38426. /**
  38427. * Sets Vignette centre X Offset.
  38428. */
  38429. vignetteCentreX: number;
  38430. /**
  38431. * Gets Vignette centre Y Offset.
  38432. */
  38433. /**
  38434. * Sets Vignette centre Y Offset.
  38435. */
  38436. vignetteCentreY: number;
  38437. /**
  38438. * Gets Vignette weight or intensity of the vignette effect.
  38439. */
  38440. /**
  38441. * Sets Vignette weight or intensity of the vignette effect.
  38442. */
  38443. vignetteWeight: number;
  38444. /**
  38445. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38446. * if vignetteEnabled is set to true.
  38447. */
  38448. /**
  38449. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38450. * if vignetteEnabled is set to true.
  38451. */
  38452. vignetteColor: Color4;
  38453. /**
  38454. * Gets Camera field of view used by the Vignette effect.
  38455. */
  38456. /**
  38457. * Sets Camera field of view used by the Vignette effect.
  38458. */
  38459. vignetteCameraFov: number;
  38460. /**
  38461. * Gets the vignette blend mode allowing different kind of effect.
  38462. */
  38463. /**
  38464. * Sets the vignette blend mode allowing different kind of effect.
  38465. */
  38466. vignetteBlendMode: number;
  38467. /**
  38468. * Gets wether the vignette effect is enabled.
  38469. */
  38470. /**
  38471. * Sets wether the vignette effect is enabled.
  38472. */
  38473. vignetteEnabled: boolean;
  38474. private _fromLinearSpace;
  38475. /**
  38476. * Gets wether the input of the processing is in Gamma or Linear Space.
  38477. */
  38478. /**
  38479. * Sets wether the input of the processing is in Gamma or Linear Space.
  38480. */
  38481. fromLinearSpace: boolean;
  38482. /**
  38483. * Defines cache preventing GC.
  38484. */
  38485. private _defines;
  38486. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  38487. /**
  38488. * "ImageProcessingPostProcess"
  38489. * @returns "ImageProcessingPostProcess"
  38490. */
  38491. getClassName(): string;
  38492. protected _updateParameters(): void;
  38493. dispose(camera?: Camera): void;
  38494. }
  38495. }
  38496. declare module BABYLON {
  38497. /**
  38498. * Class containing static functions to help procedurally build meshes
  38499. */
  38500. export class GroundBuilder {
  38501. /**
  38502. * Creates a ground mesh
  38503. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  38504. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  38505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38506. * @param name defines the name of the mesh
  38507. * @param options defines the options used to create the mesh
  38508. * @param scene defines the hosting scene
  38509. * @returns the ground mesh
  38510. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  38511. */
  38512. static CreateGround(name: string, options: {
  38513. width?: number;
  38514. height?: number;
  38515. subdivisions?: number;
  38516. subdivisionsX?: number;
  38517. subdivisionsY?: number;
  38518. updatable?: boolean;
  38519. }, scene: any): Mesh;
  38520. /**
  38521. * Creates a tiled ground mesh
  38522. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  38523. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  38524. * * 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
  38525. * * 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
  38526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38527. * @param name defines the name of the mesh
  38528. * @param options defines the options used to create the mesh
  38529. * @param scene defines the hosting scene
  38530. * @returns the tiled ground mesh
  38531. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  38532. */
  38533. static CreateTiledGround(name: string, options: {
  38534. xmin: number;
  38535. zmin: number;
  38536. xmax: number;
  38537. zmax: number;
  38538. subdivisions?: {
  38539. w: number;
  38540. h: number;
  38541. };
  38542. precision?: {
  38543. w: number;
  38544. h: number;
  38545. };
  38546. updatable?: boolean;
  38547. }, scene: Scene): Mesh;
  38548. /**
  38549. * Creates a ground mesh from a height map
  38550. * * The parameter `url` sets the URL of the height map image resource.
  38551. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  38552. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  38553. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  38554. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  38555. * * 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.
  38556. * * 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).
  38557. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  38558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38559. * @param name defines the name of the mesh
  38560. * @param url defines the url to the height map
  38561. * @param options defines the options used to create the mesh
  38562. * @param scene defines the hosting scene
  38563. * @returns the ground mesh
  38564. * @see https://doc.babylonjs.com/babylon101/height_map
  38565. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  38566. */
  38567. static CreateGroundFromHeightMap(name: string, url: string, options: {
  38568. width?: number;
  38569. height?: number;
  38570. subdivisions?: number;
  38571. minHeight?: number;
  38572. maxHeight?: number;
  38573. colorFilter?: Color3;
  38574. alphaFilter?: number;
  38575. updatable?: boolean;
  38576. onReady?: (mesh: GroundMesh) => void;
  38577. }, scene: Scene): GroundMesh;
  38578. }
  38579. }
  38580. declare module BABYLON {
  38581. /**
  38582. * Class containing static functions to help procedurally build meshes
  38583. */
  38584. export class TorusBuilder {
  38585. /**
  38586. * Creates a torus mesh
  38587. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  38588. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  38589. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  38590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38591. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38593. * @param name defines the name of the mesh
  38594. * @param options defines the options used to create the mesh
  38595. * @param scene defines the hosting scene
  38596. * @returns the torus mesh
  38597. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  38598. */
  38599. static CreateTorus(name: string, options: {
  38600. diameter?: number;
  38601. thickness?: number;
  38602. tessellation?: number;
  38603. updatable?: boolean;
  38604. sideOrientation?: number;
  38605. frontUVs?: Vector4;
  38606. backUVs?: Vector4;
  38607. }, scene: any): Mesh;
  38608. }
  38609. }
  38610. declare module BABYLON {
  38611. /**
  38612. * Class containing static functions to help procedurally build meshes
  38613. */
  38614. export class CylinderBuilder {
  38615. /**
  38616. * Creates a cylinder or a cone mesh
  38617. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  38618. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  38619. * * 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.
  38620. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  38621. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  38622. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  38623. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  38624. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  38625. * * 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).
  38626. * * 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
  38627. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  38628. * * 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
  38629. * * 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.
  38630. * * If `enclose` is false, a ring surface is one element.
  38631. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  38632. * * 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
  38633. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38634. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38636. * @param name defines the name of the mesh
  38637. * @param options defines the options used to create the mesh
  38638. * @param scene defines the hosting scene
  38639. * @returns the cylinder mesh
  38640. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  38641. */
  38642. static CreateCylinder(name: string, options: {
  38643. height?: number;
  38644. diameterTop?: number;
  38645. diameterBottom?: number;
  38646. diameter?: number;
  38647. tessellation?: number;
  38648. subdivisions?: number;
  38649. arc?: number;
  38650. faceColors?: Color4[];
  38651. faceUV?: Vector4[];
  38652. updatable?: boolean;
  38653. hasRings?: boolean;
  38654. enclose?: boolean;
  38655. sideOrientation?: number;
  38656. frontUVs?: Vector4;
  38657. backUVs?: Vector4;
  38658. }, scene: any): Mesh;
  38659. }
  38660. }
  38661. declare module BABYLON {
  38662. /**
  38663. * Manager for handling gamepads
  38664. */
  38665. export class GamepadManager {
  38666. private _scene?;
  38667. private _babylonGamepads;
  38668. private _oneGamepadConnected;
  38669. /** @hidden */ isMonitoring: boolean;
  38670. private _gamepadEventSupported;
  38671. private _gamepadSupport;
  38672. /**
  38673. * observable to be triggered when the gamepad controller has been connected
  38674. */
  38675. onGamepadConnectedObservable: Observable<Gamepad>;
  38676. /**
  38677. * observable to be triggered when the gamepad controller has been disconnected
  38678. */
  38679. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38680. private _onGamepadConnectedEvent;
  38681. private _onGamepadDisconnectedEvent;
  38682. /**
  38683. * Initializes the gamepad manager
  38684. * @param _scene BabylonJS scene
  38685. */
  38686. constructor(_scene?: Scene | undefined);
  38687. /**
  38688. * The gamepads in the game pad manager
  38689. */
  38690. readonly gamepads: Gamepad[];
  38691. /**
  38692. * Get the gamepad controllers based on type
  38693. * @param type The type of gamepad controller
  38694. * @returns Nullable gamepad
  38695. */
  38696. getGamepadByType(type?: number): Nullable<Gamepad>;
  38697. /**
  38698. * Disposes the gamepad manager
  38699. */
  38700. dispose(): void;
  38701. private _addNewGamepad;
  38702. private _startMonitoringGamepads;
  38703. private _stopMonitoringGamepads;
  38704. /** @hidden */ checkGamepadsStatus(): void;
  38705. private _updateGamepadObjects;
  38706. }
  38707. }
  38708. declare module BABYLON {
  38709. interface Scene {
  38710. /** @hidden */ gamepadManager: Nullable<GamepadManager>;
  38711. /**
  38712. * Gets the gamepad manager associated with the scene
  38713. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38714. */
  38715. gamepadManager: GamepadManager;
  38716. }
  38717. /**
  38718. * Interface representing a free camera inputs manager
  38719. */
  38720. interface FreeCameraInputsManager {
  38721. /**
  38722. * Adds gamepad input support to the FreeCameraInputsManager.
  38723. * @returns the FreeCameraInputsManager
  38724. */
  38725. addGamepad(): FreeCameraInputsManager;
  38726. }
  38727. /**
  38728. * Interface representing an arc rotate camera inputs manager
  38729. */
  38730. interface ArcRotateCameraInputsManager {
  38731. /**
  38732. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38733. * @returns the camera inputs manager
  38734. */
  38735. addGamepad(): ArcRotateCameraInputsManager;
  38736. }
  38737. /**
  38738. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38739. */
  38740. export class GamepadSystemSceneComponent implements ISceneComponent {
  38741. /**
  38742. * The component name helpfull to identify the component in the list of scene components.
  38743. */
  38744. readonly name: string;
  38745. /**
  38746. * The scene the component belongs to.
  38747. */
  38748. scene: Scene;
  38749. /**
  38750. * Creates a new instance of the component for the given scene
  38751. * @param scene Defines the scene to register the component in
  38752. */
  38753. constructor(scene: Scene);
  38754. /**
  38755. * Registers the component in a given scene
  38756. */
  38757. register(): void;
  38758. /**
  38759. * Rebuilds the elements related to this component in case of
  38760. * context lost for instance.
  38761. */
  38762. rebuild(): void;
  38763. /**
  38764. * Disposes the component and the associated ressources
  38765. */
  38766. dispose(): void;
  38767. private _beforeCameraUpdate;
  38768. }
  38769. }
  38770. declare module BABYLON {
  38771. /**
  38772. * Options to modify the vr teleportation behavior.
  38773. */
  38774. export interface VRTeleportationOptions {
  38775. /**
  38776. * The name of the mesh which should be used as the teleportation floor. (default: null)
  38777. */
  38778. floorMeshName?: string;
  38779. /**
  38780. * A list of meshes to be used as the teleportation floor. (default: empty)
  38781. */
  38782. floorMeshes?: Mesh[];
  38783. }
  38784. /**
  38785. * Options to modify the vr experience helper's behavior.
  38786. */
  38787. export interface VRExperienceHelperOptions extends WebVROptions {
  38788. /**
  38789. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  38790. */
  38791. createDeviceOrientationCamera?: boolean;
  38792. /**
  38793. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  38794. */
  38795. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  38796. /**
  38797. * Uses the main button on the controller to toggle the laser casted. (default: true)
  38798. */
  38799. laserToggle?: boolean;
  38800. /**
  38801. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  38802. */
  38803. floorMeshes?: Mesh[];
  38804. /**
  38805. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  38806. */
  38807. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  38808. }
  38809. /**
  38810. * Event containing information after VR has been entered
  38811. */
  38812. export class OnAfterEnteringVRObservableEvent {
  38813. /**
  38814. * If entering vr was successful
  38815. */
  38816. success: boolean;
  38817. }
  38818. /**
  38819. * Helps to quickly add VR support to an existing scene.
  38820. * See http://doc.babylonjs.com/how_to/webvr_helper
  38821. */
  38822. export class VRExperienceHelper {
  38823. /** Options to modify the vr experience helper's behavior. */
  38824. webVROptions: VRExperienceHelperOptions;
  38825. private _scene;
  38826. private _position;
  38827. private _btnVR;
  38828. private _btnVRDisplayed;
  38829. private _webVRsupported;
  38830. private _webVRready;
  38831. private _webVRrequesting;
  38832. private _webVRpresenting;
  38833. private _hasEnteredVR;
  38834. private _fullscreenVRpresenting;
  38835. private _canvas;
  38836. private _webVRCamera;
  38837. private _vrDeviceOrientationCamera;
  38838. private _deviceOrientationCamera;
  38839. private _existingCamera;
  38840. private _onKeyDown;
  38841. private _onVrDisplayPresentChange;
  38842. private _onVRDisplayChanged;
  38843. private _onVRRequestPresentStart;
  38844. private _onVRRequestPresentComplete;
  38845. /**
  38846. * Observable raised right before entering VR.
  38847. */
  38848. onEnteringVRObservable: Observable<VRExperienceHelper>;
  38849. /**
  38850. * Observable raised when entering VR has completed.
  38851. */
  38852. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  38853. /**
  38854. * Observable raised when exiting VR.
  38855. */
  38856. onExitingVRObservable: Observable<VRExperienceHelper>;
  38857. /**
  38858. * Observable raised when controller mesh is loaded.
  38859. */
  38860. onControllerMeshLoadedObservable: Observable<WebVRController>;
  38861. /** Return this.onEnteringVRObservable
  38862. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  38863. */
  38864. readonly onEnteringVR: Observable<VRExperienceHelper>;
  38865. /** Return this.onExitingVRObservable
  38866. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  38867. */
  38868. readonly onExitingVR: Observable<VRExperienceHelper>;
  38869. /** Return this.onControllerMeshLoadedObservable
  38870. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  38871. */
  38872. readonly onControllerMeshLoaded: Observable<WebVRController>;
  38873. private _rayLength;
  38874. private _useCustomVRButton;
  38875. private _teleportationRequested;
  38876. private _teleportActive;
  38877. private _floorMeshName;
  38878. private _floorMeshesCollection;
  38879. private _rotationAllowed;
  38880. private _teleportBackwardsVector;
  38881. private _teleportationTarget;
  38882. private _isDefaultTeleportationTarget;
  38883. private _postProcessMove;
  38884. private _teleportationFillColor;
  38885. private _teleportationBorderColor;
  38886. private _rotationAngle;
  38887. private _haloCenter;
  38888. private _cameraGazer;
  38889. private _padSensibilityUp;
  38890. private _padSensibilityDown;
  38891. private _leftController;
  38892. private _rightController;
  38893. /**
  38894. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  38895. */
  38896. onNewMeshSelected: Observable<AbstractMesh>;
  38897. /**
  38898. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  38899. */
  38900. onNewMeshPicked: Observable<PickingInfo>;
  38901. private _circleEase;
  38902. /**
  38903. * Observable raised before camera teleportation
  38904. */
  38905. onBeforeCameraTeleport: Observable<Vector3>;
  38906. /**
  38907. * Observable raised after camera teleportation
  38908. */
  38909. onAfterCameraTeleport: Observable<Vector3>;
  38910. /**
  38911. * Observable raised when current selected mesh gets unselected
  38912. */
  38913. onSelectedMeshUnselected: Observable<AbstractMesh>;
  38914. private _raySelectionPredicate;
  38915. /**
  38916. * To be optionaly changed by user to define custom ray selection
  38917. */
  38918. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  38919. /**
  38920. * To be optionaly changed by user to define custom selection logic (after ray selection)
  38921. */
  38922. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  38923. /**
  38924. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  38925. */
  38926. teleportationEnabled: boolean;
  38927. private _defaultHeight;
  38928. private _teleportationInitialized;
  38929. private _interactionsEnabled;
  38930. private _interactionsRequested;
  38931. private _displayGaze;
  38932. private _displayLaserPointer;
  38933. /**
  38934. * The mesh used to display where the user is going to teleport.
  38935. */
  38936. /**
  38937. * Sets the mesh to be used to display where the user is going to teleport.
  38938. */
  38939. teleportationTarget: Mesh;
  38940. /**
  38941. * 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
  38942. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  38943. * See http://doc.babylonjs.com/resources/baking_transformations
  38944. */
  38945. gazeTrackerMesh: Mesh;
  38946. /**
  38947. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  38948. */
  38949. updateGazeTrackerScale: boolean;
  38950. /**
  38951. * If the gaze trackers color should be updated when selecting meshes
  38952. */
  38953. updateGazeTrackerColor: boolean;
  38954. /**
  38955. * The gaze tracking mesh corresponding to the left controller
  38956. */
  38957. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  38958. /**
  38959. * The gaze tracking mesh corresponding to the right controller
  38960. */
  38961. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  38962. /**
  38963. * If the ray of the gaze should be displayed.
  38964. */
  38965. /**
  38966. * Sets if the ray of the gaze should be displayed.
  38967. */
  38968. displayGaze: boolean;
  38969. /**
  38970. * If the ray of the LaserPointer should be displayed.
  38971. */
  38972. /**
  38973. * Sets if the ray of the LaserPointer should be displayed.
  38974. */
  38975. displayLaserPointer: boolean;
  38976. /**
  38977. * The deviceOrientationCamera used as the camera when not in VR.
  38978. */
  38979. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  38980. /**
  38981. * Based on the current WebVR support, returns the current VR camera used.
  38982. */
  38983. readonly currentVRCamera: Nullable<Camera>;
  38984. /**
  38985. * The webVRCamera which is used when in VR.
  38986. */
  38987. readonly webVRCamera: WebVRFreeCamera;
  38988. /**
  38989. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  38990. */
  38991. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  38992. private readonly _teleportationRequestInitiated;
  38993. /**
  38994. * Defines wether or not Pointer lock should be requested when switching to
  38995. * full screen.
  38996. */
  38997. requestPointerLockOnFullScreen: boolean;
  38998. /**
  38999. * Instantiates a VRExperienceHelper.
  39000. * Helps to quickly add VR support to an existing scene.
  39001. * @param scene The scene the VRExperienceHelper belongs to.
  39002. * @param webVROptions Options to modify the vr experience helper's behavior.
  39003. */
  39004. constructor(scene: Scene,
  39005. /** Options to modify the vr experience helper's behavior. */
  39006. webVROptions?: VRExperienceHelperOptions);
  39007. private _onDefaultMeshLoaded;
  39008. private _onResize;
  39009. private _onFullscreenChange;
  39010. /**
  39011. * Gets a value indicating if we are currently in VR mode.
  39012. */
  39013. readonly isInVRMode: boolean;
  39014. private onVrDisplayPresentChange;
  39015. private onVRDisplayChanged;
  39016. private moveButtonToBottomRight;
  39017. private displayVRButton;
  39018. private updateButtonVisibility;
  39019. private _cachedAngularSensibility;
  39020. /**
  39021. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39022. * Otherwise, will use the fullscreen API.
  39023. */
  39024. enterVR(): void;
  39025. /**
  39026. * Attempt to exit VR, or fullscreen.
  39027. */
  39028. exitVR(): void;
  39029. /**
  39030. * The position of the vr experience helper.
  39031. */
  39032. /**
  39033. * Sets the position of the vr experience helper.
  39034. */
  39035. position: Vector3;
  39036. /**
  39037. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39038. */
  39039. enableInteractions(): void;
  39040. private readonly _noControllerIsActive;
  39041. private beforeRender;
  39042. private _isTeleportationFloor;
  39043. /**
  39044. * Adds a floor mesh to be used for teleportation.
  39045. * @param floorMesh the mesh to be used for teleportation.
  39046. */
  39047. addFloorMesh(floorMesh: Mesh): void;
  39048. /**
  39049. * Removes a floor mesh from being used for teleportation.
  39050. * @param floorMesh the mesh to be removed.
  39051. */
  39052. removeFloorMesh(floorMesh: Mesh): void;
  39053. /**
  39054. * Enables interactions and teleportation using the VR controllers and gaze.
  39055. * @param vrTeleportationOptions options to modify teleportation behavior.
  39056. */
  39057. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39058. private _onNewGamepadConnected;
  39059. private _tryEnableInteractionOnController;
  39060. private _onNewGamepadDisconnected;
  39061. private _enableInteractionOnController;
  39062. private _checkTeleportWithRay;
  39063. private _checkRotate;
  39064. private _checkTeleportBackwards;
  39065. private _enableTeleportationOnController;
  39066. private _createTeleportationCircles;
  39067. private _displayTeleportationTarget;
  39068. private _hideTeleportationTarget;
  39069. private _rotateCamera;
  39070. private _moveTeleportationSelectorTo;
  39071. private _workingVector;
  39072. private _workingQuaternion;
  39073. private _workingMatrix;
  39074. /**
  39075. * Teleports the users feet to the desired location
  39076. * @param location The location where the user's feet should be placed
  39077. */
  39078. teleportCamera(location: Vector3): void;
  39079. private _convertNormalToDirectionOfRay;
  39080. private _castRayAndSelectObject;
  39081. private _notifySelectedMeshUnselected;
  39082. /**
  39083. * Sets the color of the laser ray from the vr controllers.
  39084. * @param color new color for the ray.
  39085. */
  39086. changeLaserColor(color: Color3): void;
  39087. /**
  39088. * Sets the color of the ray from the vr headsets gaze.
  39089. * @param color new color for the ray.
  39090. */
  39091. changeGazeColor(color: Color3): void;
  39092. /**
  39093. * Exits VR and disposes of the vr experience helper
  39094. */
  39095. dispose(): void;
  39096. /**
  39097. * Gets the name of the VRExperienceHelper class
  39098. * @returns "VRExperienceHelper"
  39099. */
  39100. getClassName(): string;
  39101. }
  39102. }
  39103. declare module BABYLON {
  39104. /**
  39105. * Manages an XRSession
  39106. * @see https://doc.babylonjs.com/how_to/webxr
  39107. */
  39108. export class WebXRSessionManager implements IDisposable {
  39109. private scene;
  39110. /**
  39111. * Fires every time a new xrFrame arrives which can be used to update the camera
  39112. */
  39113. onXRFrameObservable: Observable<any>;
  39114. /**
  39115. * Fires when the xr session is ended either by the device or manually done
  39116. */
  39117. onXRSessionEnded: Observable<any>;
  39118. /** @hidden */ xrSession: XRSession;
  39119. /** @hidden */ frameOfReference: XRFrameOfReference;
  39120. /** @hidden */ sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39121. /** @hidden */ currentXRFrame: Nullable<XRFrame>;
  39122. private _xrNavigator;
  39123. private _xrDevice;
  39124. private _tmpMatrix;
  39125. /**
  39126. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39127. * @param scene The scene which the session should be created for
  39128. */
  39129. constructor(scene: Scene);
  39130. /**
  39131. * Initializes the manager
  39132. * After initialization enterXR can be called to start an XR session
  39133. * @returns Promise which resolves after it is initialized
  39134. */
  39135. initializeAsync(): Promise<void>;
  39136. /**
  39137. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39138. * @param sessionCreationOptions xr options to create the session with
  39139. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39140. * @returns Promise which resolves after it enters XR
  39141. */
  39142. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39143. /**
  39144. * Stops the xrSession and restores the renderloop
  39145. * @returns Promise which resolves after it exits XR
  39146. */
  39147. exitXRAsync(): Promise<void>;
  39148. /**
  39149. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39150. * @param ray ray to cast into the environment
  39151. * @returns Promise which resolves with a collision point in the environment if it exists
  39152. */
  39153. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39154. /**
  39155. * Checks if a session would be supported for the creation options specified
  39156. * @param options creation options to check if they are supported
  39157. * @returns true if supported
  39158. */
  39159. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39160. /**
  39161. * @hidden
  39162. * Converts the render layer of xrSession to a render target
  39163. * @param session session to create render target for
  39164. * @param scene scene the new render target should be created for
  39165. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39166. /**
  39167. * Disposes of the session manager
  39168. */
  39169. dispose(): void;
  39170. }
  39171. }
  39172. declare module BABYLON {
  39173. /**
  39174. * WebXR Camera which holds the views for the xrSession
  39175. * @see https://doc.babylonjs.com/how_to/webxr
  39176. */
  39177. export class WebXRCamera extends FreeCamera {
  39178. private static _TmpMatrix;
  39179. /**
  39180. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39181. * @param name the name of the camera
  39182. * @param scene the scene to add the camera to
  39183. */
  39184. constructor(name: string, scene: Scene);
  39185. private _updateNumberOfRigCameras;
  39186. /** @hidden */ updateForDualEyeDebugging(pupilDistance?: number): void;
  39187. /**
  39188. * Updates the cameras position from the current pose information of the XR session
  39189. * @param xrSessionManager the session containing pose information
  39190. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39191. */
  39192. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39193. }
  39194. }
  39195. declare module BABYLON {
  39196. /**
  39197. * States of the webXR experience
  39198. */
  39199. export enum WebXRState {
  39200. /**
  39201. * Transitioning to being in XR mode
  39202. */
  39203. ENTERING_XR = 0,
  39204. /**
  39205. * Transitioning to non XR mode
  39206. */
  39207. EXITING_XR = 1,
  39208. /**
  39209. * In XR mode and presenting
  39210. */
  39211. IN_XR = 2,
  39212. /**
  39213. * Not entered XR mode
  39214. */
  39215. NOT_IN_XR = 3
  39216. }
  39217. /**
  39218. * Helper class used to enable XR
  39219. * @see https://doc.babylonjs.com/how_to/webxr
  39220. */
  39221. export class WebXRExperienceHelper implements IDisposable {
  39222. private scene;
  39223. /**
  39224. * 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
  39225. */
  39226. container: AbstractMesh;
  39227. /**
  39228. * Camera used to render xr content
  39229. */
  39230. camera: WebXRCamera;
  39231. /**
  39232. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39233. */
  39234. state: WebXRState;
  39235. private _setState;
  39236. private static _TmpVector;
  39237. /**
  39238. * Fires when the state of the experience helper has changed
  39239. */
  39240. onStateChangedObservable: Observable<WebXRState>;
  39241. /** @hidden */ sessionManager: WebXRSessionManager;
  39242. private _nonVRCamera;
  39243. private _originalSceneAutoClear;
  39244. private _supported;
  39245. /**
  39246. * Creates the experience helper
  39247. * @param scene the scene to attach the experience helper to
  39248. * @returns a promise for the experience helper
  39249. */
  39250. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39251. /**
  39252. * Creates a WebXRExperienceHelper
  39253. * @param scene The scene the helper should be created in
  39254. */
  39255. private constructor();
  39256. /**
  39257. * Exits XR mode and returns the scene to its original state
  39258. * @returns promise that resolves after xr mode has exited
  39259. */
  39260. exitXRAsync(): Promise<void>;
  39261. /**
  39262. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39263. * @param sessionCreationOptions options for the XR session
  39264. * @param frameOfReference frame of reference of the XR session
  39265. * @returns promise that resolves after xr mode has entered
  39266. */
  39267. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39268. /**
  39269. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39270. * @param ray ray to cast into the environment
  39271. * @returns Promise which resolves with a collision point in the environment if it exists
  39272. */
  39273. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39274. /**
  39275. * Updates the global position of the camera by moving the camera's container
  39276. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39277. * @param position The desired global position of the camera
  39278. */
  39279. setPositionOfCameraUsingContainer(position: Vector3): void;
  39280. /**
  39281. * Rotates the xr camera by rotating the camera's container around the camera's position
  39282. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39283. * @param rotation the desired quaternion rotation to apply to the camera
  39284. */
  39285. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39286. /**
  39287. * Checks if the creation options are supported by the xr session
  39288. * @param options creation options
  39289. * @returns true if supported
  39290. */
  39291. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39292. /**
  39293. * Disposes of the experience helper
  39294. */
  39295. dispose(): void;
  39296. }
  39297. }
  39298. declare module BABYLON {
  39299. /**
  39300. * Button which can be used to enter a different mode of XR
  39301. */
  39302. export class WebXREnterExitUIButton {
  39303. /** button element */
  39304. element: HTMLElement;
  39305. /** XR initialization options for the button */
  39306. initializationOptions: XRSessionCreationOptions;
  39307. /**
  39308. * Creates a WebXREnterExitUIButton
  39309. * @param element button element
  39310. * @param initializationOptions XR initialization options for the button
  39311. */
  39312. constructor(
  39313. /** button element */
  39314. element: HTMLElement,
  39315. /** XR initialization options for the button */
  39316. initializationOptions: XRSessionCreationOptions);
  39317. /**
  39318. * Overwritable function which can be used to update the button's visuals when the state changes
  39319. * @param activeButton the current active button in the UI
  39320. */
  39321. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39322. }
  39323. /**
  39324. * Options to create the webXR UI
  39325. */
  39326. export class WebXREnterExitUIOptions {
  39327. /**
  39328. * Context to enter xr with
  39329. */
  39330. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39331. /**
  39332. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39333. */
  39334. customButtons?: Array<WebXREnterExitUIButton>;
  39335. }
  39336. /**
  39337. * UI to allow the user to enter/exit XR mode
  39338. */
  39339. export class WebXREnterExitUI implements IDisposable {
  39340. private scene;
  39341. private _overlay;
  39342. private _buttons;
  39343. private _activeButton;
  39344. /**
  39345. * Fired every time the active button is changed.
  39346. *
  39347. * When xr is entered via a button that launches xr that button will be the callback parameter
  39348. *
  39349. * When exiting xr the callback parameter will be null)
  39350. */
  39351. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39352. /**
  39353. * Creates UI to allow the user to enter/exit XR mode
  39354. * @param scene the scene to add the ui to
  39355. * @param helper the xr experience helper to enter/exit xr with
  39356. * @param options options to configure the UI
  39357. * @returns the created ui
  39358. */
  39359. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39360. private constructor();
  39361. private _updateButtons;
  39362. /**
  39363. * Disposes of the object
  39364. */
  39365. dispose(): void;
  39366. }
  39367. }
  39368. declare module BABYLON {
  39369. /**
  39370. * Represents an XR input
  39371. */
  39372. export class WebXRController {
  39373. /**
  39374. * 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
  39375. */
  39376. grip?: AbstractMesh;
  39377. /**
  39378. * Pointer which can be used to select objects or attach a visible laser to
  39379. */
  39380. pointer: AbstractMesh;
  39381. /**
  39382. * Creates the controller
  39383. * @see https://doc.babylonjs.com/how_to/webxr
  39384. * @param scene the scene which the controller should be associated to
  39385. */
  39386. constructor(scene: Scene);
  39387. /**
  39388. * Disposes of the object
  39389. */
  39390. dispose(): void;
  39391. }
  39392. /**
  39393. * XR input used to track XR inputs such as controllers/rays
  39394. */
  39395. export class WebXRInput implements IDisposable {
  39396. private helper;
  39397. /**
  39398. * XR controllers being tracked
  39399. */
  39400. controllers: Array<WebXRController>;
  39401. private _tmpMatrix;
  39402. private _frameObserver;
  39403. /**
  39404. * Initializes the WebXRInput
  39405. * @param helper experience helper which the input should be created for
  39406. */
  39407. constructor(helper: WebXRExperienceHelper);
  39408. /**
  39409. * Disposes of the object
  39410. */
  39411. dispose(): void;
  39412. }
  39413. }
  39414. declare module BABYLON {
  39415. /**
  39416. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  39417. */
  39418. export class WebXRManagedOutputCanvas implements IDisposable {
  39419. private _canvas;
  39420. /**
  39421. * xrpresent context of the canvas which can be used to display/mirror xr content
  39422. */
  39423. canvasContext: Nullable<WebGLRenderingContext>;
  39424. /**
  39425. * Initializes the canvas to be added/removed upon entering/exiting xr
  39426. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  39427. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  39428. */
  39429. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  39430. /**
  39431. * Disposes of the object
  39432. */
  39433. dispose(): void;
  39434. private _setManagedOutputCanvas;
  39435. private _addCanvas;
  39436. private _removeCanvas;
  39437. }
  39438. }
  39439. declare module BABYLON {
  39440. /**
  39441. * Contains an array of blocks representing the octree
  39442. */
  39443. export interface IOctreeContainer<T> {
  39444. /**
  39445. * Blocks within the octree
  39446. */
  39447. blocks: Array<OctreeBlock<T>>;
  39448. }
  39449. /**
  39450. * Class used to store a cell in an octree
  39451. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39452. */
  39453. export class OctreeBlock<T> {
  39454. /**
  39455. * Gets the content of the current block
  39456. */
  39457. entries: T[];
  39458. /**
  39459. * Gets the list of block children
  39460. */
  39461. blocks: Array<OctreeBlock<T>>;
  39462. private _depth;
  39463. private _maxDepth;
  39464. private _capacity;
  39465. private _minPoint;
  39466. private _maxPoint;
  39467. private _boundingVectors;
  39468. private _creationFunc;
  39469. /**
  39470. * Creates a new block
  39471. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  39472. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  39473. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39474. * @param depth defines the current depth of this block in the octree
  39475. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  39476. * @param creationFunc defines a callback to call when an element is added to the block
  39477. */
  39478. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  39479. /**
  39480. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39481. */
  39482. readonly capacity: number;
  39483. /**
  39484. * Gets the minimum vector (in world space) of the block's bounding box
  39485. */
  39486. readonly minPoint: Vector3;
  39487. /**
  39488. * Gets the maximum vector (in world space) of the block's bounding box
  39489. */
  39490. readonly maxPoint: Vector3;
  39491. /**
  39492. * Add a new element to this block
  39493. * @param entry defines the element to add
  39494. */
  39495. addEntry(entry: T): void;
  39496. /**
  39497. * Remove an element from this block
  39498. * @param entry defines the element to remove
  39499. */
  39500. removeEntry(entry: T): void;
  39501. /**
  39502. * Add an array of elements to this block
  39503. * @param entries defines the array of elements to add
  39504. */
  39505. addEntries(entries: T[]): void;
  39506. /**
  39507. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  39508. * @param frustumPlanes defines the frustum planes to test
  39509. * @param selection defines the array to store current content if selection is positive
  39510. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39511. */
  39512. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39513. /**
  39514. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  39515. * @param sphereCenter defines the bounding sphere center
  39516. * @param sphereRadius defines the bounding sphere radius
  39517. * @param selection defines the array to store current content if selection is positive
  39518. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39519. */
  39520. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39521. /**
  39522. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  39523. * @param ray defines the ray to test with
  39524. * @param selection defines the array to store current content if selection is positive
  39525. */
  39526. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  39527. /**
  39528. * Subdivide the content into child blocks (this block will then be empty)
  39529. */
  39530. createInnerBlocks(): void;
  39531. /**
  39532. * @hidden
  39533. */ private 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;
  39534. }
  39535. }
  39536. declare module BABYLON {
  39537. /**
  39538. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  39539. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39540. */
  39541. export class Octree<T> {
  39542. /** 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.) */
  39543. maxDepth: number;
  39544. /**
  39545. * Blocks within the octree containing objects
  39546. */
  39547. blocks: Array<OctreeBlock<T>>;
  39548. /**
  39549. * Content stored in the octree
  39550. */
  39551. dynamicContent: T[];
  39552. private _maxBlockCapacity;
  39553. private _selectionContent;
  39554. private _creationFunc;
  39555. /**
  39556. * Creates a octree
  39557. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39558. * @param creationFunc function to be used to instatiate the octree
  39559. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  39560. * @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.)
  39561. */
  39562. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  39563. /** 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.) */
  39564. maxDepth?: number);
  39565. /**
  39566. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  39567. * @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);
  39568. * @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);
  39569. * @param entries meshes to be added to the octree blocks
  39570. */
  39571. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  39572. /**
  39573. * Adds a mesh to the octree
  39574. * @param entry Mesh to add to the octree
  39575. */
  39576. addMesh(entry: T): void;
  39577. /**
  39578. * Remove an element from the octree
  39579. * @param entry defines the element to remove
  39580. */
  39581. removeMesh(entry: T): void;
  39582. /**
  39583. * Selects an array of meshes within the frustum
  39584. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  39585. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  39586. * @returns array of meshes within the frustum
  39587. */
  39588. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  39589. /**
  39590. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  39591. * @param sphereCenter defines the bounding sphere center
  39592. * @param sphereRadius defines the bounding sphere radius
  39593. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39594. * @returns an array of objects that intersect the sphere
  39595. */
  39596. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  39597. /**
  39598. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  39599. * @param ray defines the ray to test with
  39600. * @returns array of intersected objects
  39601. */
  39602. intersectsRay(ray: Ray): SmartArray<T>;
  39603. /**
  39604. * Adds a mesh into the octree block if it intersects the block
  39605. */
  39606. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  39607. /**
  39608. * Adds a submesh into the octree block if it intersects the block
  39609. */
  39610. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  39611. }
  39612. }
  39613. declare module BABYLON {
  39614. interface Scene {
  39615. /**
  39616. * @hidden
  39617. * Backing Filed
  39618. */ selectionOctree: Octree<AbstractMesh>;
  39619. /**
  39620. * Gets the octree used to boost mesh selection (picking)
  39621. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39622. */
  39623. selectionOctree: Octree<AbstractMesh>;
  39624. /**
  39625. * Creates or updates the octree used to boost selection (picking)
  39626. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39627. * @param maxCapacity defines the maximum capacity per leaf
  39628. * @param maxDepth defines the maximum depth of the octree
  39629. * @returns an octree of AbstractMesh
  39630. */
  39631. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  39632. }
  39633. interface AbstractMesh {
  39634. /**
  39635. * @hidden
  39636. * Backing Field
  39637. */ submeshesOctree: Octree<SubMesh>;
  39638. /**
  39639. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  39640. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  39641. * @param maxCapacity defines the maximum size of each block (64 by default)
  39642. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  39643. * @returns the new octree
  39644. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  39645. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39646. */
  39647. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  39648. }
  39649. /**
  39650. * Defines the octree scene component responsible to manage any octrees
  39651. * in a given scene.
  39652. */
  39653. export class OctreeSceneComponent {
  39654. /**
  39655. * The component name helpfull to identify the component in the list of scene components.
  39656. */
  39657. readonly name: string;
  39658. /**
  39659. * The scene the component belongs to.
  39660. */
  39661. scene: Scene;
  39662. /**
  39663. * Indicates if the meshes have been checked to make sure they are isEnabled()
  39664. */
  39665. readonly checksIsEnabled: boolean;
  39666. /**
  39667. * Creates a new instance of the component for the given scene
  39668. * @param scene Defines the scene to register the component in
  39669. */
  39670. constructor(scene: Scene);
  39671. /**
  39672. * Registers the component in a given scene
  39673. */
  39674. register(): void;
  39675. /**
  39676. * Return the list of active meshes
  39677. * @returns the list of active meshes
  39678. */
  39679. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39680. /**
  39681. * Return the list of active sub meshes
  39682. * @param mesh The mesh to get the candidates sub meshes from
  39683. * @returns the list of active sub meshes
  39684. */
  39685. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39686. private _tempRay;
  39687. /**
  39688. * Return the list of sub meshes intersecting with a given local ray
  39689. * @param mesh defines the mesh to find the submesh for
  39690. * @param localRay defines the ray in local space
  39691. * @returns the list of intersecting sub meshes
  39692. */
  39693. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  39694. /**
  39695. * Return the list of sub meshes colliding with a collider
  39696. * @param mesh defines the mesh to find the submesh for
  39697. * @param collider defines the collider to evaluate the collision against
  39698. * @returns the list of colliding sub meshes
  39699. */
  39700. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  39701. /**
  39702. * Rebuilds the elements related to this component in case of
  39703. * context lost for instance.
  39704. */
  39705. rebuild(): void;
  39706. /**
  39707. * Disposes the component and the associated ressources.
  39708. */
  39709. dispose(): void;
  39710. }
  39711. }
  39712. declare module BABYLON {
  39713. /**
  39714. * Renders a layer on top of an existing scene
  39715. */
  39716. export class UtilityLayerRenderer implements IDisposable {
  39717. /** the original scene that will be rendered on top of */
  39718. originalScene: Scene;
  39719. private _pointerCaptures;
  39720. private _lastPointerEvents;
  39721. private static _DefaultUtilityLayer;
  39722. private static _DefaultKeepDepthUtilityLayer;
  39723. private _sharedGizmoLight;
  39724. /**
  39725. * @hidden
  39726. * Light which used by gizmos to get light shading
  39727. */ getSharedGizmoLight(): HemisphericLight;
  39728. /**
  39729. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  39730. */
  39731. pickUtilitySceneFirst: boolean;
  39732. /**
  39733. * 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)
  39734. */
  39735. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  39736. /**
  39737. * 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)
  39738. */
  39739. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  39740. /**
  39741. * The scene that is rendered on top of the original scene
  39742. */
  39743. utilityLayerScene: Scene;
  39744. /**
  39745. * If the utility layer should automatically be rendered on top of existing scene
  39746. */
  39747. shouldRender: boolean;
  39748. /**
  39749. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  39750. */
  39751. onlyCheckPointerDownEvents: boolean;
  39752. /**
  39753. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  39754. */
  39755. processAllEvents: boolean;
  39756. /**
  39757. * Observable raised when the pointer move from the utility layer scene to the main scene
  39758. */
  39759. onPointerOutObservable: Observable<number>;
  39760. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  39761. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  39762. private _afterRenderObserver;
  39763. private _sceneDisposeObserver;
  39764. private _originalPointerObserver;
  39765. /**
  39766. * Instantiates a UtilityLayerRenderer
  39767. * @param originalScene the original scene that will be rendered on top of
  39768. * @param handleEvents boolean indicating if the utility layer should handle events
  39769. */
  39770. constructor(
  39771. /** the original scene that will be rendered on top of */
  39772. originalScene: Scene, handleEvents?: boolean);
  39773. private _notifyObservers;
  39774. /**
  39775. * Renders the utility layers scene on top of the original scene
  39776. */
  39777. render(): void;
  39778. /**
  39779. * Disposes of the renderer
  39780. */
  39781. dispose(): void;
  39782. private _updateCamera;
  39783. }
  39784. }
  39785. declare module BABYLON {
  39786. /**
  39787. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  39788. */
  39789. export class Gizmo implements IDisposable {
  39790. /** The utility layer the gizmo will be added to */
  39791. gizmoLayer: UtilityLayerRenderer;
  39792. /**
  39793. * The root mesh of the gizmo
  39794. */ rootMesh: Mesh;
  39795. private _attachedMesh;
  39796. /**
  39797. * Ratio for the scale of the gizmo (Default: 1)
  39798. */
  39799. scaleRatio: number;
  39800. private _tmpMatrix;
  39801. /**
  39802. * If a custom mesh has been set (Default: false)
  39803. */
  39804. protected _customMeshSet: boolean;
  39805. /**
  39806. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  39807. * * When set, interactions will be enabled
  39808. */
  39809. attachedMesh: Nullable<AbstractMesh>;
  39810. /**
  39811. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  39812. * @param mesh The mesh to replace the default mesh of the gizmo
  39813. */
  39814. setCustomMesh(mesh: Mesh): void;
  39815. /**
  39816. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  39817. */
  39818. updateGizmoRotationToMatchAttachedMesh: boolean;
  39819. /**
  39820. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  39821. */
  39822. updateGizmoPositionToMatchAttachedMesh: boolean;
  39823. /**
  39824. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  39825. */
  39826. protected _updateScale: boolean;
  39827. protected _interactionsEnabled: boolean;
  39828. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39829. private _beforeRenderObserver;
  39830. /**
  39831. * Creates a gizmo
  39832. * @param gizmoLayer The utility layer the gizmo will be added to
  39833. */
  39834. constructor(
  39835. /** The utility layer the gizmo will be added to */
  39836. gizmoLayer?: UtilityLayerRenderer);
  39837. private _tempVector;
  39838. /**
  39839. * @hidden
  39840. * Updates the gizmo to match the attached mesh's position/rotation
  39841. */
  39842. protected _update(): void;
  39843. /**
  39844. * Disposes of the gizmo
  39845. */
  39846. dispose(): void;
  39847. }
  39848. }
  39849. declare module BABYLON {
  39850. /**
  39851. * Single axis drag gizmo
  39852. */
  39853. export class AxisDragGizmo extends Gizmo {
  39854. /**
  39855. * Drag behavior responsible for the gizmos dragging interactions
  39856. */
  39857. dragBehavior: PointerDragBehavior;
  39858. private _pointerObserver;
  39859. /**
  39860. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39861. */
  39862. snapDistance: number;
  39863. /**
  39864. * Event that fires each time the gizmo snaps to a new location.
  39865. * * snapDistance is the the change in distance
  39866. */
  39867. onSnapObservable: Observable<{
  39868. snapDistance: number;
  39869. }>;
  39870. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  39871. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  39872. /**
  39873. * Creates an AxisDragGizmo
  39874. * @param gizmoLayer The utility layer the gizmo will be added to
  39875. * @param dragAxis The axis which the gizmo will be able to drag on
  39876. * @param color The color of the gizmo
  39877. */
  39878. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  39879. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39880. /**
  39881. * Disposes of the gizmo
  39882. */
  39883. dispose(): void;
  39884. }
  39885. }
  39886. declare module BABYLON.Debug {
  39887. /**
  39888. * The Axes viewer will show 3 axes in a specific point in space
  39889. */
  39890. export class AxesViewer {
  39891. private _xAxis;
  39892. private _yAxis;
  39893. private _zAxis;
  39894. private _scaleLinesFactor;
  39895. private _instanced;
  39896. /**
  39897. * Gets the hosting scene
  39898. */
  39899. scene: Scene;
  39900. /**
  39901. * Gets or sets a number used to scale line length
  39902. */
  39903. scaleLines: number;
  39904. /** Gets the node hierarchy used to render x-axis */
  39905. readonly xAxis: TransformNode;
  39906. /** Gets the node hierarchy used to render y-axis */
  39907. readonly yAxis: TransformNode;
  39908. /** Gets the node hierarchy used to render z-axis */
  39909. readonly zAxis: TransformNode;
  39910. /**
  39911. * Creates a new AxesViewer
  39912. * @param scene defines the hosting scene
  39913. * @param scaleLines defines a number used to scale line length (1 by default)
  39914. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  39915. * @param xAxis defines the node hierarchy used to render the x-axis
  39916. * @param yAxis defines the node hierarchy used to render the y-axis
  39917. * @param zAxis defines the node hierarchy used to render the z-axis
  39918. */
  39919. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  39920. /**
  39921. * Force the viewer to update
  39922. * @param position defines the position of the viewer
  39923. * @param xaxis defines the x axis of the viewer
  39924. * @param yaxis defines the y axis of the viewer
  39925. * @param zaxis defines the z axis of the viewer
  39926. */
  39927. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  39928. /**
  39929. * Creates an instance of this axes viewer.
  39930. * @returns a new axes viewer with instanced meshes
  39931. */
  39932. createInstance(): AxesViewer;
  39933. /** Releases resources */
  39934. dispose(): void;
  39935. private static _SetRenderingGroupId;
  39936. }
  39937. }
  39938. declare module BABYLON.Debug {
  39939. /**
  39940. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  39941. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  39942. */
  39943. export class BoneAxesViewer extends AxesViewer {
  39944. /**
  39945. * Gets or sets the target mesh where to display the axes viewer
  39946. */
  39947. mesh: Nullable<Mesh>;
  39948. /**
  39949. * Gets or sets the target bone where to display the axes viewer
  39950. */
  39951. bone: Nullable<Bone>;
  39952. /** Gets current position */
  39953. pos: Vector3;
  39954. /** Gets direction of X axis */
  39955. xaxis: Vector3;
  39956. /** Gets direction of Y axis */
  39957. yaxis: Vector3;
  39958. /** Gets direction of Z axis */
  39959. zaxis: Vector3;
  39960. /**
  39961. * Creates a new BoneAxesViewer
  39962. * @param scene defines the hosting scene
  39963. * @param bone defines the target bone
  39964. * @param mesh defines the target mesh
  39965. * @param scaleLines defines a scaling factor for line length (1 by default)
  39966. */
  39967. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  39968. /**
  39969. * Force the viewer to update
  39970. */
  39971. update(): void;
  39972. /** Releases resources */
  39973. dispose(): void;
  39974. }
  39975. }
  39976. declare module BABYLON {
  39977. /**
  39978. * Interface used to define scene explorer extensibility option
  39979. */
  39980. export interface IExplorerExtensibilityOption {
  39981. /**
  39982. * Define the option label
  39983. */
  39984. label: string;
  39985. /**
  39986. * Defines the action to execute on click
  39987. */
  39988. action: (entity: any) => void;
  39989. }
  39990. /**
  39991. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  39992. */
  39993. export interface IExplorerExtensibilityGroup {
  39994. /**
  39995. * Defines a predicate to test if a given type mut be extended
  39996. */
  39997. predicate: (entity: any) => boolean;
  39998. /**
  39999. * Gets the list of options added to a type
  40000. */
  40001. entries: IExplorerExtensibilityOption[];
  40002. }
  40003. /**
  40004. * Interface used to define the options to use to create the Inspector
  40005. */
  40006. export interface IInspectorOptions {
  40007. /**
  40008. * Display in overlay mode (default: false)
  40009. */
  40010. overlay?: boolean;
  40011. /**
  40012. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40013. */
  40014. globalRoot?: HTMLElement;
  40015. /**
  40016. * Display the Scene explorer
  40017. */
  40018. showExplorer?: boolean;
  40019. /**
  40020. * Display the property inspector
  40021. */
  40022. showInspector?: boolean;
  40023. /**
  40024. * Display in embed mode (both panes on the right)
  40025. */
  40026. embedMode?: boolean;
  40027. /**
  40028. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40029. */
  40030. handleResize?: boolean;
  40031. /**
  40032. * Allow the panes to popup (default: true)
  40033. */
  40034. enablePopup?: boolean;
  40035. /**
  40036. * Allow the panes to be closed by users (default: true)
  40037. */
  40038. enableClose?: boolean;
  40039. /**
  40040. * Optional list of extensibility entries
  40041. */
  40042. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40043. /**
  40044. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40045. */
  40046. inspectorURL?: string;
  40047. }
  40048. interface Scene {
  40049. /**
  40050. * @hidden
  40051. * Backing field
  40052. */ debugLayer: DebugLayer;
  40053. /**
  40054. * Gets the debug layer (aka Inspector) associated with the scene
  40055. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40056. */
  40057. debugLayer: DebugLayer;
  40058. }
  40059. /**
  40060. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40061. * what is happening in your scene
  40062. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40063. */
  40064. export class DebugLayer {
  40065. /**
  40066. * Define the url to get the inspector script from.
  40067. * By default it uses the babylonjs CDN.
  40068. * @ignoreNaming
  40069. */
  40070. static InspectorURL: string;
  40071. private _scene;
  40072. private BJSINSPECTOR;
  40073. /**
  40074. * Observable triggered when a property is changed through the inspector.
  40075. */
  40076. onPropertyChangedObservable: Observable<{
  40077. object: any;
  40078. property: string;
  40079. value: any;
  40080. initialValue: any;
  40081. }>;
  40082. /**
  40083. * Instantiates a new debug layer.
  40084. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40085. * what is happening in your scene
  40086. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40087. * @param scene Defines the scene to inspect
  40088. */
  40089. constructor(scene: Scene);
  40090. /** Creates the inspector window. */
  40091. private _createInspector;
  40092. /**
  40093. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40094. * @param entity defines the entity to select
  40095. * @param lineContainerTitle defines the specific block to highlight
  40096. */
  40097. select(entity: any, lineContainerTitle?: string): void;
  40098. /** Get the inspector from bundle or global */
  40099. private _getGlobalInspector;
  40100. /**
  40101. * Get if the inspector is visible or not.
  40102. * @returns true if visible otherwise, false
  40103. */
  40104. isVisible(): boolean;
  40105. /**
  40106. * Hide the inspector and close its window.
  40107. */
  40108. hide(): void;
  40109. /**
  40110. * Launch the debugLayer.
  40111. * @param config Define the configuration of the inspector
  40112. * @return a promise fulfilled when the debug layer is visible
  40113. */
  40114. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40115. }
  40116. }
  40117. declare module BABYLON {
  40118. /**
  40119. * Class containing static functions to help procedurally build meshes
  40120. */
  40121. export class BoxBuilder {
  40122. /**
  40123. * Creates a box mesh
  40124. * * The parameter `size` sets the size (float) of each box side (default 1)
  40125. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40126. * * 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)
  40127. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40129. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40131. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40132. * @param name defines the name of the mesh
  40133. * @param options defines the options used to create the mesh
  40134. * @param scene defines the hosting scene
  40135. * @returns the box mesh
  40136. */
  40137. static CreateBox(name: string, options: {
  40138. size?: number;
  40139. width?: number;
  40140. height?: number;
  40141. depth?: number;
  40142. faceUV?: Vector4[];
  40143. faceColors?: Color4[];
  40144. sideOrientation?: number;
  40145. frontUVs?: Vector4;
  40146. backUVs?: Vector4;
  40147. updatable?: boolean;
  40148. }, scene?: Nullable<Scene>): Mesh;
  40149. }
  40150. }
  40151. declare module BABYLON {
  40152. /**
  40153. * Class containing static functions to help procedurally build meshes
  40154. */
  40155. export class SphereBuilder {
  40156. /**
  40157. * Creates a sphere mesh
  40158. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40159. * * 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`)
  40160. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40161. * * 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
  40162. * * 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)
  40163. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40164. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40166. * @param name defines the name of the mesh
  40167. * @param options defines the options used to create the mesh
  40168. * @param scene defines the hosting scene
  40169. * @returns the sphere mesh
  40170. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40171. */
  40172. static CreateSphere(name: string, options: {
  40173. segments?: number;
  40174. diameter?: number;
  40175. diameterX?: number;
  40176. diameterY?: number;
  40177. diameterZ?: number;
  40178. arc?: number;
  40179. slice?: number;
  40180. sideOrientation?: number;
  40181. frontUVs?: Vector4;
  40182. backUVs?: Vector4;
  40183. updatable?: boolean;
  40184. }, scene: any): Mesh;
  40185. }
  40186. }
  40187. declare module BABYLON.Debug {
  40188. /**
  40189. * Used to show the physics impostor around the specific mesh
  40190. */
  40191. export class PhysicsViewer {
  40192. /** @hidden */
  40193. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40194. /** @hidden */
  40195. protected _meshes: Array<Nullable<AbstractMesh>>;
  40196. /** @hidden */
  40197. protected _scene: Nullable<Scene>;
  40198. /** @hidden */
  40199. protected _numMeshes: number;
  40200. /** @hidden */
  40201. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40202. private _renderFunction;
  40203. private _utilityLayer;
  40204. private _debugBoxMesh;
  40205. private _debugSphereMesh;
  40206. private _debugMaterial;
  40207. private _debugMeshMeshes;
  40208. /**
  40209. * Creates a new PhysicsViewer
  40210. * @param scene defines the hosting scene
  40211. */
  40212. constructor(scene: Scene);
  40213. /** @hidden */
  40214. protected _updateDebugMeshes(): void;
  40215. /**
  40216. * Renders a specified physic impostor
  40217. * @param impostor defines the impostor to render
  40218. * @param targetMesh defines the mesh represented by the impostor
  40219. * @returns the new debug mesh used to render the impostor
  40220. */
  40221. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  40222. /**
  40223. * Hides a specified physic impostor
  40224. * @param impostor defines the impostor to hide
  40225. */
  40226. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40227. private _getDebugMaterial;
  40228. private _getDebugBoxMesh;
  40229. private _getDebugSphereMesh;
  40230. private _getDebugMeshMesh;
  40231. private _getDebugMesh;
  40232. /** Releases all resources */
  40233. dispose(): void;
  40234. }
  40235. }
  40236. declare module BABYLON {
  40237. /**
  40238. * Class containing static functions to help procedurally build meshes
  40239. */
  40240. export class LinesBuilder {
  40241. /**
  40242. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40243. * * 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
  40244. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40245. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40246. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40247. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40248. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40249. * * 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
  40250. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40252. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40253. * @param name defines the name of the new line system
  40254. * @param options defines the options used to create the line system
  40255. * @param scene defines the hosting scene
  40256. * @returns a new line system mesh
  40257. */
  40258. static CreateLineSystem(name: string, options: {
  40259. lines: Vector3[][];
  40260. updatable?: boolean;
  40261. instance?: Nullable<LinesMesh>;
  40262. colors?: Nullable<Color4[][]>;
  40263. useVertexAlpha?: boolean;
  40264. }, scene: Nullable<Scene>): LinesMesh;
  40265. /**
  40266. * Creates a line mesh
  40267. * 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
  40268. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40269. * * The parameter `points` is an array successive Vector3
  40270. * * 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
  40271. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40272. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40273. * * When updating an instance, remember that only point positions can change, not the number of points
  40274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40275. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40276. * @param name defines the name of the new line system
  40277. * @param options defines the options used to create the line system
  40278. * @param scene defines the hosting scene
  40279. * @returns a new line mesh
  40280. */
  40281. static CreateLines(name: string, options: {
  40282. points: Vector3[];
  40283. updatable?: boolean;
  40284. instance?: Nullable<LinesMesh>;
  40285. colors?: Color4[];
  40286. useVertexAlpha?: boolean;
  40287. }, scene?: Nullable<Scene>): LinesMesh;
  40288. /**
  40289. * Creates a dashed line mesh
  40290. * * 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
  40291. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40292. * * The parameter `points` is an array successive Vector3
  40293. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40294. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40295. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40296. * * 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
  40297. * * When updating an instance, remember that only point positions can change, not the number of points
  40298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40299. * @param name defines the name of the mesh
  40300. * @param options defines the options used to create the mesh
  40301. * @param scene defines the hosting scene
  40302. * @returns the dashed line mesh
  40303. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40304. */
  40305. static CreateDashedLines(name: string, options: {
  40306. points: Vector3[];
  40307. dashSize?: number;
  40308. gapSize?: number;
  40309. dashNb?: number;
  40310. updatable?: boolean;
  40311. instance?: LinesMesh;
  40312. }, scene?: Nullable<Scene>): LinesMesh;
  40313. }
  40314. }
  40315. declare module BABYLON {
  40316. /**
  40317. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40318. * in order to better appreciate the issue one might have.
  40319. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40320. */
  40321. export class RayHelper {
  40322. /**
  40323. * Defines the ray we are currently tryin to visualize.
  40324. */
  40325. ray: Nullable<Ray>;
  40326. private _renderPoints;
  40327. private _renderLine;
  40328. private _renderFunction;
  40329. private _scene;
  40330. private _updateToMeshFunction;
  40331. private _attachedToMesh;
  40332. private _meshSpaceDirection;
  40333. private _meshSpaceOrigin;
  40334. /**
  40335. * Helper function to create a colored helper in a scene in one line.
  40336. * @param ray Defines the ray we are currently tryin to visualize
  40337. * @param scene Defines the scene the ray is used in
  40338. * @param color Defines the color we want to see the ray in
  40339. * @returns The newly created ray helper.
  40340. */
  40341. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  40342. /**
  40343. * Instantiate a new ray helper.
  40344. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40345. * in order to better appreciate the issue one might have.
  40346. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40347. * @param ray Defines the ray we are currently tryin to visualize
  40348. */
  40349. constructor(ray: Ray);
  40350. /**
  40351. * Shows the ray we are willing to debug.
  40352. * @param scene Defines the scene the ray needs to be rendered in
  40353. * @param color Defines the color the ray needs to be rendered in
  40354. */
  40355. show(scene: Scene, color?: Color3): void;
  40356. /**
  40357. * Hides the ray we are debugging.
  40358. */
  40359. hide(): void;
  40360. private _render;
  40361. /**
  40362. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  40363. * @param mesh Defines the mesh we want the helper attached to
  40364. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  40365. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  40366. * @param length Defines the length of the ray
  40367. */
  40368. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  40369. /**
  40370. * Detach the ray helper from the mesh it has previously been attached to.
  40371. */
  40372. detachFromMesh(): void;
  40373. private _updateToMesh;
  40374. /**
  40375. * Dispose the helper and release its associated resources.
  40376. */
  40377. dispose(): void;
  40378. }
  40379. }
  40380. declare module BABYLON.Debug {
  40381. /**
  40382. * Class used to render a debug view of a given skeleton
  40383. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  40384. */
  40385. export class SkeletonViewer {
  40386. /** defines the skeleton to render */
  40387. skeleton: Skeleton;
  40388. /** defines the mesh attached to the skeleton */
  40389. mesh: AbstractMesh;
  40390. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40391. autoUpdateBonesMatrices: boolean;
  40392. /** defines the rendering group id to use with the viewer */
  40393. renderingGroupId: number;
  40394. /** Gets or sets the color used to render the skeleton */
  40395. color: Color3;
  40396. private _scene;
  40397. private _debugLines;
  40398. private _debugMesh;
  40399. private _isEnabled;
  40400. private _renderFunction;
  40401. private _utilityLayer;
  40402. /**
  40403. * Returns the mesh used to render the bones
  40404. */
  40405. readonly debugMesh: Nullable<LinesMesh>;
  40406. /**
  40407. * Creates a new SkeletonViewer
  40408. * @param skeleton defines the skeleton to render
  40409. * @param mesh defines the mesh attached to the skeleton
  40410. * @param scene defines the hosting scene
  40411. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  40412. * @param renderingGroupId defines the rendering group id to use with the viewer
  40413. */
  40414. constructor(
  40415. /** defines the skeleton to render */
  40416. skeleton: Skeleton,
  40417. /** defines the mesh attached to the skeleton */
  40418. mesh: AbstractMesh, scene: Scene,
  40419. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40420. autoUpdateBonesMatrices?: boolean,
  40421. /** defines the rendering group id to use with the viewer */
  40422. renderingGroupId?: number);
  40423. /** Gets or sets a boolean indicating if the viewer is enabled */
  40424. isEnabled: boolean;
  40425. private _getBonePosition;
  40426. private _getLinesForBonesWithLength;
  40427. private _getLinesForBonesNoLength;
  40428. /** Update the viewer to sync with current skeleton state */
  40429. update(): void;
  40430. /** Release associated resources */
  40431. dispose(): void;
  40432. }
  40433. }
  40434. declare module BABYLON {
  40435. /**
  40436. * Options to create the null engine
  40437. */
  40438. export class NullEngineOptions {
  40439. /**
  40440. * Render width (Default: 512)
  40441. */
  40442. renderWidth: number;
  40443. /**
  40444. * Render height (Default: 256)
  40445. */
  40446. renderHeight: number;
  40447. /**
  40448. * Texture size (Default: 512)
  40449. */
  40450. textureSize: number;
  40451. /**
  40452. * If delta time between frames should be constant
  40453. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40454. */
  40455. deterministicLockstep: boolean;
  40456. /**
  40457. * Maximum about of steps between frames (Default: 4)
  40458. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40459. */
  40460. lockstepMaxSteps: number;
  40461. }
  40462. /**
  40463. * The null engine class provides support for headless version of babylon.js.
  40464. * This can be used in server side scenario or for testing purposes
  40465. */
  40466. export class NullEngine extends Engine {
  40467. private _options;
  40468. /**
  40469. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40470. */
  40471. isDeterministicLockStep(): boolean;
  40472. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  40473. getLockstepMaxSteps(): number;
  40474. /**
  40475. * Sets hardware scaling, used to save performance if needed
  40476. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  40477. */
  40478. getHardwareScalingLevel(): number;
  40479. constructor(options?: NullEngineOptions);
  40480. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40481. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  40482. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40483. getRenderWidth(useScreen?: boolean): number;
  40484. getRenderHeight(useScreen?: boolean): number;
  40485. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  40486. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  40487. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  40488. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  40489. bindSamplers(effect: Effect): void;
  40490. enableEffect(effect: Effect): void;
  40491. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40492. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  40493. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  40494. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  40495. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  40496. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  40497. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  40498. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  40499. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  40500. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  40501. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  40502. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  40503. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  40504. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  40505. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  40506. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40507. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40508. setFloat(uniform: WebGLUniformLocation, value: number): void;
  40509. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  40510. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  40511. setBool(uniform: WebGLUniformLocation, bool: number): void;
  40512. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  40513. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  40514. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  40515. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  40516. bindBuffers(vertexBuffers: {
  40517. [key: string]: VertexBuffer;
  40518. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  40519. wipeCaches(bruteForce?: boolean): void;
  40520. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40521. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40522. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40523. /** @hidden */ createTexture(): WebGLTexture;
  40524. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  40525. 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;
  40526. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  40527. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  40528. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  40529. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40530. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40531. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  40532. areAllEffectsReady(): boolean;
  40533. /**
  40534. * @hidden
  40535. * Get the current error code of the webGL context
  40536. * @returns the error code
  40537. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40538. */
  40539. getError(): number;
  40540. /** @hidden */ getUnpackAlignement(): number;
  40541. /** @hidden */ unpackFlipY(value: boolean): void;
  40542. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  40543. /**
  40544. * Updates a dynamic vertex buffer.
  40545. * @param vertexBuffer the vertex buffer to update
  40546. * @param data the data used to update the vertex buffer
  40547. * @param byteOffset the byte offset of the data (optional)
  40548. * @param byteLength the byte length of the data (optional)
  40549. */
  40550. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  40551. /** @hidden */ bindTexture(channel: number, texture: InternalTexture): void;
  40552. /** @hidden */ releaseBuffer(buffer: WebGLBuffer): boolean;
  40553. releaseEffects(): void;
  40554. displayLoadingUI(): void;
  40555. hideLoadingUI(): void;
  40556. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40557. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40558. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40559. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  40560. }
  40561. }
  40562. declare module BABYLON {
  40563. /** @hidden */
  40564. export class _OcclusionDataStorage {
  40565. /** @hidden */
  40566. occlusionInternalRetryCounter: number;
  40567. /** @hidden */
  40568. isOcclusionQueryInProgress: boolean;
  40569. /** @hidden */
  40570. isOccluded: boolean;
  40571. /** @hidden */
  40572. occlusionRetryCount: number;
  40573. /** @hidden */
  40574. occlusionType: number;
  40575. /** @hidden */
  40576. occlusionQueryAlgorithmType: number;
  40577. }
  40578. interface Engine {
  40579. /**
  40580. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  40581. * @return the new query
  40582. */
  40583. createQuery(): WebGLQuery;
  40584. /**
  40585. * Delete and release a webGL query
  40586. * @param query defines the query to delete
  40587. * @return the current engine
  40588. */
  40589. deleteQuery(query: WebGLQuery): Engine;
  40590. /**
  40591. * Check if a given query has resolved and got its value
  40592. * @param query defines the query to check
  40593. * @returns true if the query got its value
  40594. */
  40595. isQueryResultAvailable(query: WebGLQuery): boolean;
  40596. /**
  40597. * Gets the value of a given query
  40598. * @param query defines the query to check
  40599. * @returns the value of the query
  40600. */
  40601. getQueryResult(query: WebGLQuery): number;
  40602. /**
  40603. * Initiates an occlusion query
  40604. * @param algorithmType defines the algorithm to use
  40605. * @param query defines the query to use
  40606. * @returns the current engine
  40607. * @see http://doc.babylonjs.com/features/occlusionquery
  40608. */
  40609. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  40610. /**
  40611. * Ends an occlusion query
  40612. * @see http://doc.babylonjs.com/features/occlusionquery
  40613. * @param algorithmType defines the algorithm to use
  40614. * @returns the current engine
  40615. */
  40616. endOcclusionQuery(algorithmType: number): Engine;
  40617. /**
  40618. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  40619. * Please note that only one query can be issued at a time
  40620. * @returns a time token used to track the time span
  40621. */
  40622. startTimeQuery(): Nullable<_TimeToken>;
  40623. /**
  40624. * Ends a time query
  40625. * @param token defines the token used to measure the time span
  40626. * @returns the time spent (in ns)
  40627. */
  40628. endTimeQuery(token: _TimeToken): int;
  40629. /** @hidden */ currentNonTimestampToken: Nullable<_TimeToken>;
  40630. /** @hidden */ createTimeQuery(): WebGLQuery;
  40631. /** @hidden */ deleteTimeQuery(query: WebGLQuery): void;
  40632. /** @hidden */ getGlAlgorithmType(algorithmType: number): number;
  40633. /** @hidden */ getTimeQueryResult(query: WebGLQuery): any;
  40634. /** @hidden */ getTimeQueryAvailability(query: WebGLQuery): any;
  40635. }
  40636. interface AbstractMesh {
  40637. /**
  40638. * Backing filed
  40639. * @hidden
  40640. */ private _occlusionDataStorage: _OcclusionDataStorage;
  40641. /**
  40642. * Access property
  40643. * @hidden
  40644. */ occlusionDataStorage: _OcclusionDataStorage;
  40645. /**
  40646. * 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.
  40647. * The default value is -1 which means don't break the query and wait till the result
  40648. * @see http://doc.babylonjs.com/features/occlusionquery
  40649. */
  40650. occlusionRetryCount: number;
  40651. /**
  40652. * 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:
  40653. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  40654. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  40655. * * 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.
  40656. * @see http://doc.babylonjs.com/features/occlusionquery
  40657. */
  40658. occlusionType: number;
  40659. /**
  40660. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  40661. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  40662. * * 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.
  40663. * @see http://doc.babylonjs.com/features/occlusionquery
  40664. */
  40665. occlusionQueryAlgorithmType: number;
  40666. /**
  40667. * 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
  40668. * @see http://doc.babylonjs.com/features/occlusionquery
  40669. */
  40670. isOccluded: boolean;
  40671. /**
  40672. * Flag to check the progress status of the query
  40673. * @see http://doc.babylonjs.com/features/occlusionquery
  40674. */
  40675. isOcclusionQueryInProgress: boolean;
  40676. }
  40677. }
  40678. declare module BABYLON {
  40679. /** @hidden */
  40680. export var _forceTransformFeedbackToBundle: boolean;
  40681. interface Engine {
  40682. /**
  40683. * Creates a webGL transform feedback object
  40684. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  40685. * @returns the webGL transform feedback object
  40686. */
  40687. createTransformFeedback(): WebGLTransformFeedback;
  40688. /**
  40689. * Delete a webGL transform feedback object
  40690. * @param value defines the webGL transform feedback object to delete
  40691. */
  40692. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  40693. /**
  40694. * Bind a webGL transform feedback object to the webgl context
  40695. * @param value defines the webGL transform feedback object to bind
  40696. */
  40697. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  40698. /**
  40699. * Begins a transform feedback operation
  40700. * @param usePoints defines if points or triangles must be used
  40701. */
  40702. beginTransformFeedback(usePoints: boolean): void;
  40703. /**
  40704. * Ends a transform feedback operation
  40705. */
  40706. endTransformFeedback(): void;
  40707. /**
  40708. * Specify the varyings to use with transform feedback
  40709. * @param program defines the associated webGL program
  40710. * @param value defines the list of strings representing the varying names
  40711. */
  40712. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  40713. /**
  40714. * Bind a webGL buffer for a transform feedback operation
  40715. * @param value defines the webGL buffer to bind
  40716. */
  40717. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  40718. }
  40719. }
  40720. declare module BABYLON {
  40721. /**
  40722. * Gather the list of clipboard event types as constants.
  40723. */
  40724. export class ClipboardEventTypes {
  40725. /**
  40726. * The clipboard event is fired when a copy command is active (pressed).
  40727. */
  40728. static readonly COPY: number;
  40729. /**
  40730. * The clipboard event is fired when a cut command is active (pressed).
  40731. */
  40732. static readonly CUT: number;
  40733. /**
  40734. * The clipboard event is fired when a paste command is active (pressed).
  40735. */
  40736. static readonly PASTE: number;
  40737. }
  40738. /**
  40739. * This class is used to store clipboard related info for the onClipboardObservable event.
  40740. */
  40741. export class ClipboardInfo {
  40742. /**
  40743. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40744. */
  40745. type: number;
  40746. /**
  40747. * Defines the related dom event
  40748. */
  40749. event: ClipboardEvent;
  40750. /**
  40751. *Creates an instance of ClipboardInfo.
  40752. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  40753. * @param event Defines the related dom event
  40754. */
  40755. constructor(
  40756. /**
  40757. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40758. */
  40759. type: number,
  40760. /**
  40761. * Defines the related dom event
  40762. */
  40763. event: ClipboardEvent);
  40764. /**
  40765. * Get the clipboard event's type from the keycode.
  40766. * @param keyCode Defines the keyCode for the current keyboard event.
  40767. * @return {number}
  40768. */
  40769. static GetTypeFromCharacter(keyCode: number): number;
  40770. }
  40771. }
  40772. declare module BABYLON {
  40773. /**
  40774. * Class used to represent data loading progression
  40775. */
  40776. export class SceneLoaderProgressEvent {
  40777. /** defines if data length to load can be evaluated */
  40778. readonly lengthComputable: boolean;
  40779. /** defines the loaded data length */
  40780. readonly loaded: number;
  40781. /** defines the data length to load */
  40782. readonly total: number;
  40783. /**
  40784. * Create a new progress event
  40785. * @param lengthComputable defines if data length to load can be evaluated
  40786. * @param loaded defines the loaded data length
  40787. * @param total defines the data length to load
  40788. */
  40789. constructor(
  40790. /** defines if data length to load can be evaluated */
  40791. lengthComputable: boolean,
  40792. /** defines the loaded data length */
  40793. loaded: number,
  40794. /** defines the data length to load */
  40795. total: number);
  40796. /**
  40797. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  40798. * @param event defines the source event
  40799. * @returns a new SceneLoaderProgressEvent
  40800. */
  40801. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  40802. }
  40803. /**
  40804. * Interface used by SceneLoader plugins to define supported file extensions
  40805. */
  40806. export interface ISceneLoaderPluginExtensions {
  40807. /**
  40808. * Defines the list of supported extensions
  40809. */
  40810. [extension: string]: {
  40811. isBinary: boolean;
  40812. };
  40813. }
  40814. /**
  40815. * Interface used by SceneLoader plugin factory
  40816. */
  40817. export interface ISceneLoaderPluginFactory {
  40818. /**
  40819. * Defines the name of the factory
  40820. */
  40821. name: string;
  40822. /**
  40823. * Function called to create a new plugin
  40824. * @return the new plugin
  40825. */
  40826. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  40827. /**
  40828. * Boolean indicating if the plugin can direct load specific data
  40829. */
  40830. canDirectLoad?: (data: string) => boolean;
  40831. }
  40832. /**
  40833. * Interface used to define a SceneLoader plugin
  40834. */
  40835. export interface ISceneLoaderPlugin {
  40836. /**
  40837. * The friendly name of this plugin.
  40838. */
  40839. name: string;
  40840. /**
  40841. * The file extensions supported by this plugin.
  40842. */
  40843. extensions: string | ISceneLoaderPluginExtensions;
  40844. /**
  40845. * Import meshes into a scene.
  40846. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40847. * @param scene The scene to import into
  40848. * @param data The data to import
  40849. * @param rootUrl The root url for scene and resources
  40850. * @param meshes The meshes array to import into
  40851. * @param particleSystems The particle systems array to import into
  40852. * @param skeletons The skeletons array to import into
  40853. * @param onError The callback when import fails
  40854. * @returns True if successful or false otherwise
  40855. */
  40856. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  40857. /**
  40858. * Load into a scene.
  40859. * @param scene The scene to load into
  40860. * @param data The data to import
  40861. * @param rootUrl The root url for scene and resources
  40862. * @param onError The callback when import fails
  40863. * @returns true if successful or false otherwise
  40864. */
  40865. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  40866. /**
  40867. * The callback that returns true if the data can be directly loaded.
  40868. */
  40869. canDirectLoad?: (data: string) => boolean;
  40870. /**
  40871. * The callback that allows custom handling of the root url based on the response url.
  40872. */
  40873. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40874. /**
  40875. * Load into an asset container.
  40876. * @param scene The scene to load into
  40877. * @param data The data to import
  40878. * @param rootUrl The root url for scene and resources
  40879. * @param onError The callback when import fails
  40880. * @returns The loaded asset container
  40881. */
  40882. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  40883. }
  40884. /**
  40885. * Interface used to define an async SceneLoader plugin
  40886. */
  40887. export interface ISceneLoaderPluginAsync {
  40888. /**
  40889. * The friendly name of this plugin.
  40890. */
  40891. name: string;
  40892. /**
  40893. * The file extensions supported by this plugin.
  40894. */
  40895. extensions: string | ISceneLoaderPluginExtensions;
  40896. /**
  40897. * Import meshes into a scene.
  40898. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40899. * @param scene The scene to import into
  40900. * @param data The data to import
  40901. * @param rootUrl The root url for scene and resources
  40902. * @param onProgress The callback when the load progresses
  40903. * @param fileName Defines the name of the file to load
  40904. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  40905. */
  40906. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  40907. meshes: AbstractMesh[];
  40908. particleSystems: IParticleSystem[];
  40909. skeletons: Skeleton[];
  40910. animationGroups: AnimationGroup[];
  40911. }>;
  40912. /**
  40913. * Load into a scene.
  40914. * @param scene The scene to load into
  40915. * @param data The data to import
  40916. * @param rootUrl The root url for scene and resources
  40917. * @param onProgress The callback when the load progresses
  40918. * @param fileName Defines the name of the file to load
  40919. * @returns Nothing
  40920. */
  40921. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  40922. /**
  40923. * The callback that returns true if the data can be directly loaded.
  40924. */
  40925. canDirectLoad?: (data: string) => boolean;
  40926. /**
  40927. * The callback that allows custom handling of the root url based on the response url.
  40928. */
  40929. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40930. /**
  40931. * Load into an asset container.
  40932. * @param scene The scene to load into
  40933. * @param data The data to import
  40934. * @param rootUrl The root url for scene and resources
  40935. * @param onProgress The callback when the load progresses
  40936. * @param fileName Defines the name of the file to load
  40937. * @returns The loaded asset container
  40938. */
  40939. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  40940. }
  40941. /**
  40942. * Class used to load scene from various file formats using registered plugins
  40943. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  40944. */
  40945. export class SceneLoader {
  40946. /**
  40947. * No logging while loading
  40948. */
  40949. static readonly NO_LOGGING: number;
  40950. /**
  40951. * Minimal logging while loading
  40952. */
  40953. static readonly MINIMAL_LOGGING: number;
  40954. /**
  40955. * Summary logging while loading
  40956. */
  40957. static readonly SUMMARY_LOGGING: number;
  40958. /**
  40959. * Detailled logging while loading
  40960. */
  40961. static readonly DETAILED_LOGGING: number;
  40962. /**
  40963. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  40964. */
  40965. static ForceFullSceneLoadingForIncremental: boolean;
  40966. /**
  40967. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  40968. */
  40969. static ShowLoadingScreen: boolean;
  40970. /**
  40971. * Defines the current logging level (while loading the scene)
  40972. * @ignorenaming
  40973. */
  40974. static loggingLevel: number;
  40975. /**
  40976. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  40977. */
  40978. static CleanBoneMatrixWeights: boolean;
  40979. /**
  40980. * Event raised when a plugin is used to load a scene
  40981. */
  40982. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  40983. private static _registeredPlugins;
  40984. private static _getDefaultPlugin;
  40985. private static _getPluginForExtension;
  40986. private static _getPluginForDirectLoad;
  40987. private static _getPluginForFilename;
  40988. private static _getDirectLoad;
  40989. private static _loadData;
  40990. private static _getFileInfo;
  40991. /**
  40992. * Gets a plugin that can load the given extension
  40993. * @param extension defines the extension to load
  40994. * @returns a plugin or null if none works
  40995. */
  40996. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  40997. /**
  40998. * Gets a boolean indicating that the given extension can be loaded
  40999. * @param extension defines the extension to load
  41000. * @returns true if the extension is supported
  41001. */
  41002. static IsPluginForExtensionAvailable(extension: string): boolean;
  41003. /**
  41004. * Adds a new plugin to the list of registered plugins
  41005. * @param plugin defines the plugin to add
  41006. */
  41007. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41008. /**
  41009. * Import meshes into a scene
  41010. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41011. * @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)
  41012. * @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)
  41013. * @param scene the instance of BABYLON.Scene to append to
  41014. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41015. * @param onProgress a callback with a progress event for each file being loaded
  41016. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41017. * @param pluginExtension the extension used to determine the plugin
  41018. * @returns The loaded plugin
  41019. */
  41020. 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>;
  41021. /**
  41022. * Import meshes into a scene
  41023. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41024. * @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)
  41025. * @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)
  41026. * @param scene the instance of BABYLON.Scene to append to
  41027. * @param onProgress a callback with a progress event for each file being loaded
  41028. * @param pluginExtension the extension used to determine the plugin
  41029. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41030. */
  41031. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41032. meshes: AbstractMesh[];
  41033. particleSystems: IParticleSystem[];
  41034. skeletons: Skeleton[];
  41035. animationGroups: AnimationGroup[];
  41036. }>;
  41037. /**
  41038. * Load a scene
  41039. * @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)
  41040. * @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)
  41041. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41042. * @param onSuccess a callback with the scene when import succeeds
  41043. * @param onProgress a callback with a progress event for each file being loaded
  41044. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41045. * @param pluginExtension the extension used to determine the plugin
  41046. * @returns The loaded plugin
  41047. */
  41048. 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>;
  41049. /**
  41050. * Load a scene
  41051. * @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)
  41052. * @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)
  41053. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41054. * @param onProgress a callback with a progress event for each file being loaded
  41055. * @param pluginExtension the extension used to determine the plugin
  41056. * @returns The loaded scene
  41057. */
  41058. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41059. /**
  41060. * Append a scene
  41061. * @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)
  41062. * @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)
  41063. * @param scene is the instance of BABYLON.Scene to append to
  41064. * @param onSuccess a callback with the scene when import succeeds
  41065. * @param onProgress a callback with a progress event for each file being loaded
  41066. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41067. * @param pluginExtension the extension used to determine the plugin
  41068. * @returns The loaded plugin
  41069. */
  41070. 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>;
  41071. /**
  41072. * Append a scene
  41073. * @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)
  41074. * @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)
  41075. * @param scene is the instance of BABYLON.Scene to append to
  41076. * @param onProgress a callback with a progress event for each file being loaded
  41077. * @param pluginExtension the extension used to determine the plugin
  41078. * @returns The given scene
  41079. */
  41080. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41081. /**
  41082. * Load a scene into an asset container
  41083. * @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)
  41084. * @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)
  41085. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41086. * @param onSuccess a callback with the scene when import succeeds
  41087. * @param onProgress a callback with a progress event for each file being loaded
  41088. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41089. * @param pluginExtension the extension used to determine the plugin
  41090. * @returns The loaded plugin
  41091. */
  41092. 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>;
  41093. /**
  41094. * Load a scene into an asset container
  41095. * @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)
  41096. * @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)
  41097. * @param scene is the instance of Scene to append to
  41098. * @param onProgress a callback with a progress event for each file being loaded
  41099. * @param pluginExtension the extension used to determine the plugin
  41100. * @returns The loaded asset container
  41101. */
  41102. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41103. }
  41104. }
  41105. declare module BABYLON {
  41106. /**
  41107. * Google Daydream controller
  41108. */
  41109. export class DaydreamController extends WebVRController {
  41110. /**
  41111. * Base Url for the controller model.
  41112. */
  41113. static MODEL_BASE_URL: string;
  41114. /**
  41115. * File name for the controller model.
  41116. */
  41117. static MODEL_FILENAME: string;
  41118. /**
  41119. * Gamepad Id prefix used to identify Daydream Controller.
  41120. */
  41121. static readonly GAMEPAD_ID_PREFIX: string;
  41122. /**
  41123. * Creates a new DaydreamController from a gamepad
  41124. * @param vrGamepad the gamepad that the controller should be created from
  41125. */
  41126. constructor(vrGamepad: any);
  41127. /**
  41128. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41129. * @param scene scene in which to add meshes
  41130. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41131. */
  41132. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41133. /**
  41134. * Called once for each button that changed state since the last frame
  41135. * @param buttonIdx Which button index changed
  41136. * @param state New state of the button
  41137. * @param changes Which properties on the state changed since last frame
  41138. */
  41139. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41140. }
  41141. }
  41142. declare module BABYLON {
  41143. /**
  41144. * Gear VR Controller
  41145. */
  41146. export class GearVRController extends WebVRController {
  41147. /**
  41148. * Base Url for the controller model.
  41149. */
  41150. static MODEL_BASE_URL: string;
  41151. /**
  41152. * File name for the controller model.
  41153. */
  41154. static MODEL_FILENAME: string;
  41155. /**
  41156. * Gamepad Id prefix used to identify this controller.
  41157. */
  41158. static readonly GAMEPAD_ID_PREFIX: string;
  41159. private readonly _buttonIndexToObservableNameMap;
  41160. /**
  41161. * Creates a new GearVRController from a gamepad
  41162. * @param vrGamepad the gamepad that the controller should be created from
  41163. */
  41164. constructor(vrGamepad: any);
  41165. /**
  41166. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41167. * @param scene scene in which to add meshes
  41168. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41169. */
  41170. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41171. /**
  41172. * Called once for each button that changed state since the last frame
  41173. * @param buttonIdx Which button index changed
  41174. * @param state New state of the button
  41175. * @param changes Which properties on the state changed since last frame
  41176. */
  41177. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41178. }
  41179. }
  41180. declare module BABYLON {
  41181. /**
  41182. * Generic Controller
  41183. */
  41184. export class GenericController extends WebVRController {
  41185. /**
  41186. * Base Url for the controller model.
  41187. */
  41188. static readonly MODEL_BASE_URL: string;
  41189. /**
  41190. * File name for the controller model.
  41191. */
  41192. static readonly MODEL_FILENAME: string;
  41193. /**
  41194. * Creates a new GenericController from a gamepad
  41195. * @param vrGamepad the gamepad that the controller should be created from
  41196. */
  41197. constructor(vrGamepad: any);
  41198. /**
  41199. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41200. * @param scene scene in which to add meshes
  41201. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41202. */
  41203. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41204. /**
  41205. * Called once for each button that changed state since the last frame
  41206. * @param buttonIdx Which button index changed
  41207. * @param state New state of the button
  41208. * @param changes Which properties on the state changed since last frame
  41209. */
  41210. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41211. }
  41212. }
  41213. declare module BABYLON {
  41214. /**
  41215. * Oculus Touch Controller
  41216. */
  41217. export class OculusTouchController extends WebVRController {
  41218. /**
  41219. * Base Url for the controller model.
  41220. */
  41221. static MODEL_BASE_URL: string;
  41222. /**
  41223. * File name for the left controller model.
  41224. */
  41225. static MODEL_LEFT_FILENAME: string;
  41226. /**
  41227. * File name for the right controller model.
  41228. */
  41229. static MODEL_RIGHT_FILENAME: string;
  41230. /**
  41231. * Fired when the secondary trigger on this controller is modified
  41232. */
  41233. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41234. /**
  41235. * Fired when the thumb rest on this controller is modified
  41236. */
  41237. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41238. /**
  41239. * Creates a new OculusTouchController from a gamepad
  41240. * @param vrGamepad the gamepad that the controller should be created from
  41241. */
  41242. constructor(vrGamepad: any);
  41243. /**
  41244. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41245. * @param scene scene in which to add meshes
  41246. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41247. */
  41248. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41249. /**
  41250. * Fired when the A button on this controller is modified
  41251. */
  41252. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41253. /**
  41254. * Fired when the B button on this controller is modified
  41255. */
  41256. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41257. /**
  41258. * Fired when the X button on this controller is modified
  41259. */
  41260. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41261. /**
  41262. * Fired when the Y button on this controller is modified
  41263. */
  41264. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41265. /**
  41266. * Called once for each button that changed state since the last frame
  41267. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41268. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41269. * 2) secondary trigger (same)
  41270. * 3) A (right) X (left), touch, pressed = value
  41271. * 4) B / Y
  41272. * 5) thumb rest
  41273. * @param buttonIdx Which button index changed
  41274. * @param state New state of the button
  41275. * @param changes Which properties on the state changed since last frame
  41276. */
  41277. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41278. }
  41279. }
  41280. declare module BABYLON {
  41281. /**
  41282. * Vive Controller
  41283. */
  41284. export class ViveController extends WebVRController {
  41285. /**
  41286. * Base Url for the controller model.
  41287. */
  41288. static MODEL_BASE_URL: string;
  41289. /**
  41290. * File name for the controller model.
  41291. */
  41292. static MODEL_FILENAME: string;
  41293. /**
  41294. * Creates a new ViveController from a gamepad
  41295. * @param vrGamepad the gamepad that the controller should be created from
  41296. */
  41297. constructor(vrGamepad: any);
  41298. /**
  41299. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41300. * @param scene scene in which to add meshes
  41301. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41302. */
  41303. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41304. /**
  41305. * Fired when the left button on this controller is modified
  41306. */
  41307. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41308. /**
  41309. * Fired when the right button on this controller is modified
  41310. */
  41311. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41312. /**
  41313. * Fired when the menu button on this controller is modified
  41314. */
  41315. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41316. /**
  41317. * Called once for each button that changed state since the last frame
  41318. * Vive mapping:
  41319. * 0: touchpad
  41320. * 1: trigger
  41321. * 2: left AND right buttons
  41322. * 3: menu button
  41323. * @param buttonIdx Which button index changed
  41324. * @param state New state of the button
  41325. * @param changes Which properties on the state changed since last frame
  41326. */
  41327. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41328. }
  41329. }
  41330. declare module BABYLON {
  41331. /**
  41332. * Defines the WindowsMotionController object that the state of the windows motion controller
  41333. */
  41334. export class WindowsMotionController extends WebVRController {
  41335. /**
  41336. * The base url used to load the left and right controller models
  41337. */
  41338. static MODEL_BASE_URL: string;
  41339. /**
  41340. * The name of the left controller model file
  41341. */
  41342. static MODEL_LEFT_FILENAME: string;
  41343. /**
  41344. * The name of the right controller model file
  41345. */
  41346. static MODEL_RIGHT_FILENAME: string;
  41347. /**
  41348. * The controller name prefix for this controller type
  41349. */
  41350. static readonly GAMEPAD_ID_PREFIX: string;
  41351. /**
  41352. * The controller id pattern for this controller type
  41353. */
  41354. private static readonly GAMEPAD_ID_PATTERN;
  41355. private _loadedMeshInfo;
  41356. private readonly _mapping;
  41357. /**
  41358. * Fired when the trackpad on this controller is clicked
  41359. */
  41360. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41361. /**
  41362. * Fired when the trackpad on this controller is modified
  41363. */
  41364. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41365. /**
  41366. * The current x and y values of this controller's trackpad
  41367. */
  41368. trackpad: StickValues;
  41369. /**
  41370. * Creates a new WindowsMotionController from a gamepad
  41371. * @param vrGamepad the gamepad that the controller should be created from
  41372. */
  41373. constructor(vrGamepad: any);
  41374. /**
  41375. * Fired when the trigger on this controller is modified
  41376. */
  41377. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41378. /**
  41379. * Fired when the menu button on this controller is modified
  41380. */
  41381. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41382. /**
  41383. * Fired when the grip button on this controller is modified
  41384. */
  41385. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41386. /**
  41387. * Fired when the thumbstick button on this controller is modified
  41388. */
  41389. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41390. /**
  41391. * Fired when the touchpad button on this controller is modified
  41392. */
  41393. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41394. /**
  41395. * Fired when the touchpad values on this controller are modified
  41396. */
  41397. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41398. private _updateTrackpad;
  41399. /**
  41400. * Called once per frame by the engine.
  41401. */
  41402. update(): void;
  41403. /**
  41404. * Called once for each button that changed state since the last frame
  41405. * @param buttonIdx Which button index changed
  41406. * @param state New state of the button
  41407. * @param changes Which properties on the state changed since last frame
  41408. */
  41409. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41410. /**
  41411. * Moves the buttons on the controller mesh based on their current state
  41412. * @param buttonName the name of the button to move
  41413. * @param buttonValue the value of the button which determines the buttons new position
  41414. */
  41415. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41416. /**
  41417. * Moves the axis on the controller mesh based on its current state
  41418. * @param axis the index of the axis
  41419. * @param axisValue the value of the axis which determines the meshes new position
  41420. * @hidden
  41421. */
  41422. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41423. /**
  41424. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41425. * @param scene scene in which to add meshes
  41426. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41427. */
  41428. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41429. /**
  41430. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41431. * can be transformed by button presses and axes values, based on this._mapping.
  41432. *
  41433. * @param scene scene in which the meshes exist
  41434. * @param meshes list of meshes that make up the controller model to process
  41435. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41436. */
  41437. private processModel;
  41438. private createMeshInfo;
  41439. /**
  41440. * Gets the ray of the controller in the direction the controller is pointing
  41441. * @param length the length the resulting ray should be
  41442. * @returns a ray in the direction the controller is pointing
  41443. */
  41444. getForwardRay(length?: number): Ray;
  41445. /**
  41446. * Disposes of the controller
  41447. */
  41448. dispose(): void;
  41449. }
  41450. }
  41451. declare module BABYLON {
  41452. /**
  41453. * Single axis scale gizmo
  41454. */
  41455. export class AxisScaleGizmo extends Gizmo {
  41456. private _coloredMaterial;
  41457. /**
  41458. * Drag behavior responsible for the gizmos dragging interactions
  41459. */
  41460. dragBehavior: PointerDragBehavior;
  41461. private _pointerObserver;
  41462. /**
  41463. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41464. */
  41465. snapDistance: number;
  41466. /**
  41467. * Event that fires each time the gizmo snaps to a new location.
  41468. * * snapDistance is the the change in distance
  41469. */
  41470. onSnapObservable: Observable<{
  41471. snapDistance: number;
  41472. }>;
  41473. /**
  41474. * If the scaling operation should be done on all axis (default: false)
  41475. */
  41476. uniformScaling: boolean;
  41477. /**
  41478. * Creates an AxisScaleGizmo
  41479. * @param gizmoLayer The utility layer the gizmo will be added to
  41480. * @param dragAxis The axis which the gizmo will be able to scale on
  41481. * @param color The color of the gizmo
  41482. */
  41483. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41484. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41485. /**
  41486. * Disposes of the gizmo
  41487. */
  41488. dispose(): void;
  41489. /**
  41490. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41491. * @param mesh The mesh to replace the default mesh of the gizmo
  41492. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  41493. */
  41494. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  41495. }
  41496. }
  41497. declare module BABYLON {
  41498. /**
  41499. * Bounding box gizmo
  41500. */
  41501. export class BoundingBoxGizmo extends Gizmo {
  41502. private _lineBoundingBox;
  41503. private _rotateSpheresParent;
  41504. private _scaleBoxesParent;
  41505. private _boundingDimensions;
  41506. private _renderObserver;
  41507. private _pointerObserver;
  41508. private _scaleDragSpeed;
  41509. private _tmpQuaternion;
  41510. private _tmpVector;
  41511. private _tmpRotationMatrix;
  41512. /**
  41513. * 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)
  41514. */
  41515. ignoreChildren: boolean;
  41516. /**
  41517. * 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)
  41518. */
  41519. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  41520. /**
  41521. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  41522. */
  41523. rotationSphereSize: number;
  41524. /**
  41525. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  41526. */
  41527. scaleBoxSize: number;
  41528. /**
  41529. * 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)
  41530. */
  41531. fixedDragMeshScreenSize: boolean;
  41532. /**
  41533. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  41534. */
  41535. fixedDragMeshScreenSizeDistanceFactor: number;
  41536. /**
  41537. * Fired when a rotation sphere or scale box is dragged
  41538. */
  41539. onDragStartObservable: Observable<{}>;
  41540. /**
  41541. * Fired when a scale box is dragged
  41542. */
  41543. onScaleBoxDragObservable: Observable<{}>;
  41544. /**
  41545. * Fired when a scale box drag is ended
  41546. */
  41547. onScaleBoxDragEndObservable: Observable<{}>;
  41548. /**
  41549. * Fired when a rotation sphere is dragged
  41550. */
  41551. onRotationSphereDragObservable: Observable<{}>;
  41552. /**
  41553. * Fired when a rotation sphere drag is ended
  41554. */
  41555. onRotationSphereDragEndObservable: Observable<{}>;
  41556. /**
  41557. * 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)
  41558. */
  41559. scalePivot: Nullable<Vector3>;
  41560. private _anchorMesh;
  41561. private _existingMeshScale;
  41562. private _dragMesh;
  41563. private pointerDragBehavior;
  41564. private coloredMaterial;
  41565. private hoverColoredMaterial;
  41566. /**
  41567. * Sets the color of the bounding box gizmo
  41568. * @param color the color to set
  41569. */
  41570. setColor(color: Color3): void;
  41571. /**
  41572. * Creates an BoundingBoxGizmo
  41573. * @param gizmoLayer The utility layer the gizmo will be added to
  41574. * @param color The color of the gizmo
  41575. */
  41576. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41577. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41578. private _selectNode;
  41579. /**
  41580. * Updates the bounding box information for the Gizmo
  41581. */
  41582. updateBoundingBox(): void;
  41583. private _updateRotationSpheres;
  41584. private _updateScaleBoxes;
  41585. /**
  41586. * Enables rotation on the specified axis and disables rotation on the others
  41587. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  41588. */
  41589. setEnabledRotationAxis(axis: string): void;
  41590. /**
  41591. * Enables/disables scaling
  41592. * @param enable if scaling should be enabled
  41593. */
  41594. setEnabledScaling(enable: boolean): void;
  41595. private _updateDummy;
  41596. /**
  41597. * Enables a pointer drag behavior on the bounding box of the gizmo
  41598. */
  41599. enableDragBehavior(): void;
  41600. /**
  41601. * Disposes of the gizmo
  41602. */
  41603. dispose(): void;
  41604. /**
  41605. * 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)
  41606. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  41607. * @returns the bounding box mesh with the passed in mesh as a child
  41608. */
  41609. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  41610. /**
  41611. * CustomMeshes are not supported by this gizmo
  41612. * @param mesh The mesh to replace the default mesh of the gizmo
  41613. */
  41614. setCustomMesh(mesh: Mesh): void;
  41615. }
  41616. }
  41617. declare module BABYLON {
  41618. /**
  41619. * Single plane rotation gizmo
  41620. */
  41621. export class PlaneRotationGizmo extends Gizmo {
  41622. /**
  41623. * Drag behavior responsible for the gizmos dragging interactions
  41624. */
  41625. dragBehavior: PointerDragBehavior;
  41626. private _pointerObserver;
  41627. /**
  41628. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  41629. */
  41630. snapDistance: number;
  41631. /**
  41632. * Event that fires each time the gizmo snaps to a new location.
  41633. * * snapDistance is the the change in distance
  41634. */
  41635. onSnapObservable: Observable<{
  41636. snapDistance: number;
  41637. }>;
  41638. /**
  41639. * Creates a PlaneRotationGizmo
  41640. * @param gizmoLayer The utility layer the gizmo will be added to
  41641. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  41642. * @param color The color of the gizmo
  41643. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41644. */
  41645. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41646. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41647. /**
  41648. * Disposes of the gizmo
  41649. */
  41650. dispose(): void;
  41651. }
  41652. }
  41653. declare module BABYLON {
  41654. /**
  41655. * Gizmo that enables rotating a mesh along 3 axis
  41656. */
  41657. export class RotationGizmo extends Gizmo {
  41658. /**
  41659. * Internal gizmo used for interactions on the x axis
  41660. */
  41661. xGizmo: PlaneRotationGizmo;
  41662. /**
  41663. * Internal gizmo used for interactions on the y axis
  41664. */
  41665. yGizmo: PlaneRotationGizmo;
  41666. /**
  41667. * Internal gizmo used for interactions on the z axis
  41668. */
  41669. zGizmo: PlaneRotationGizmo;
  41670. /** Fires an event when any of it's sub gizmos are dragged */
  41671. onDragStartObservable: Observable<{}>;
  41672. /** Fires an event when any of it's sub gizmos are released from dragging */
  41673. onDragEndObservable: Observable<{}>;
  41674. attachedMesh: Nullable<AbstractMesh>;
  41675. /**
  41676. * Creates a RotationGizmo
  41677. * @param gizmoLayer The utility layer the gizmo will be added to
  41678. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41679. */
  41680. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41681. updateGizmoRotationToMatchAttachedMesh: boolean;
  41682. /**
  41683. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41684. */
  41685. snapDistance: number;
  41686. /**
  41687. * Ratio for the scale of the gizmo (Default: 1)
  41688. */
  41689. scaleRatio: number;
  41690. /**
  41691. * Disposes of the gizmo
  41692. */
  41693. dispose(): void;
  41694. /**
  41695. * CustomMeshes are not supported by this gizmo
  41696. * @param mesh The mesh to replace the default mesh of the gizmo
  41697. */
  41698. setCustomMesh(mesh: Mesh): void;
  41699. }
  41700. }
  41701. declare module BABYLON {
  41702. /**
  41703. * Gizmo that enables dragging a mesh along 3 axis
  41704. */
  41705. export class PositionGizmo extends Gizmo {
  41706. /**
  41707. * Internal gizmo used for interactions on the x axis
  41708. */
  41709. xGizmo: AxisDragGizmo;
  41710. /**
  41711. * Internal gizmo used for interactions on the y axis
  41712. */
  41713. yGizmo: AxisDragGizmo;
  41714. /**
  41715. * Internal gizmo used for interactions on the z axis
  41716. */
  41717. zGizmo: AxisDragGizmo;
  41718. /** Fires an event when any of it's sub gizmos are dragged */
  41719. onDragStartObservable: Observable<{}>;
  41720. /** Fires an event when any of it's sub gizmos are released from dragging */
  41721. onDragEndObservable: Observable<{}>;
  41722. attachedMesh: Nullable<AbstractMesh>;
  41723. /**
  41724. * Creates a PositionGizmo
  41725. * @param gizmoLayer The utility layer the gizmo will be added to
  41726. */
  41727. constructor(gizmoLayer?: UtilityLayerRenderer);
  41728. updateGizmoRotationToMatchAttachedMesh: boolean;
  41729. /**
  41730. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41731. */
  41732. snapDistance: number;
  41733. /**
  41734. * Ratio for the scale of the gizmo (Default: 1)
  41735. */
  41736. scaleRatio: number;
  41737. /**
  41738. * Disposes of the gizmo
  41739. */
  41740. dispose(): void;
  41741. /**
  41742. * CustomMeshes are not supported by this gizmo
  41743. * @param mesh The mesh to replace the default mesh of the gizmo
  41744. */
  41745. setCustomMesh(mesh: Mesh): void;
  41746. }
  41747. }
  41748. declare module BABYLON {
  41749. /**
  41750. * Class containing static functions to help procedurally build meshes
  41751. */
  41752. export class PolyhedronBuilder {
  41753. /**
  41754. * Creates a polyhedron mesh
  41755. * * 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
  41756. * * The parameter `size` (positive float, default 1) sets the polygon size
  41757. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  41758. * * 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`
  41759. * * 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
  41760. * * 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)`)
  41761. * * 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
  41762. * * 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
  41763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41764. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41766. * @param name defines the name of the mesh
  41767. * @param options defines the options used to create the mesh
  41768. * @param scene defines the hosting scene
  41769. * @returns the polyhedron mesh
  41770. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  41771. */
  41772. static CreatePolyhedron(name: string, options: {
  41773. type?: number;
  41774. size?: number;
  41775. sizeX?: number;
  41776. sizeY?: number;
  41777. sizeZ?: number;
  41778. custom?: any;
  41779. faceUV?: Vector4[];
  41780. faceColors?: Color4[];
  41781. flat?: boolean;
  41782. updatable?: boolean;
  41783. sideOrientation?: number;
  41784. frontUVs?: Vector4;
  41785. backUVs?: Vector4;
  41786. }, scene: Scene): Mesh;
  41787. }
  41788. }
  41789. declare module BABYLON {
  41790. /**
  41791. * Gizmo that enables scaling a mesh along 3 axis
  41792. */
  41793. export class ScaleGizmo extends Gizmo {
  41794. /**
  41795. * Internal gizmo used for interactions on the x axis
  41796. */
  41797. xGizmo: AxisScaleGizmo;
  41798. /**
  41799. * Internal gizmo used for interactions on the y axis
  41800. */
  41801. yGizmo: AxisScaleGizmo;
  41802. /**
  41803. * Internal gizmo used for interactions on the z axis
  41804. */
  41805. zGizmo: AxisScaleGizmo;
  41806. /**
  41807. * Internal gizmo used to scale all axis equally
  41808. */
  41809. uniformScaleGizmo: AxisScaleGizmo;
  41810. /** Fires an event when any of it's sub gizmos are dragged */
  41811. onDragStartObservable: Observable<{}>;
  41812. /** Fires an event when any of it's sub gizmos are released from dragging */
  41813. onDragEndObservable: Observable<{}>;
  41814. attachedMesh: Nullable<AbstractMesh>;
  41815. /**
  41816. * Creates a ScaleGizmo
  41817. * @param gizmoLayer The utility layer the gizmo will be added to
  41818. */
  41819. constructor(gizmoLayer?: UtilityLayerRenderer);
  41820. updateGizmoRotationToMatchAttachedMesh: boolean;
  41821. /**
  41822. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41823. */
  41824. snapDistance: number;
  41825. /**
  41826. * Ratio for the scale of the gizmo (Default: 1)
  41827. */
  41828. scaleRatio: number;
  41829. /**
  41830. * Disposes of the gizmo
  41831. */
  41832. dispose(): void;
  41833. }
  41834. }
  41835. declare module BABYLON {
  41836. /**
  41837. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  41838. */
  41839. export class GizmoManager implements IDisposable {
  41840. private scene;
  41841. /**
  41842. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  41843. */
  41844. gizmos: {
  41845. positionGizmo: Nullable<PositionGizmo>;
  41846. rotationGizmo: Nullable<RotationGizmo>;
  41847. scaleGizmo: Nullable<ScaleGizmo>;
  41848. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  41849. };
  41850. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  41851. clearGizmoOnEmptyPointerEvent: boolean;
  41852. /** Fires an event when the manager is attached to a mesh */
  41853. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  41854. private _gizmosEnabled;
  41855. private _pointerObserver;
  41856. private _attachedMesh;
  41857. private _boundingBoxColor;
  41858. private _defaultUtilityLayer;
  41859. private _defaultKeepDepthUtilityLayer;
  41860. /**
  41861. * When bounding box gizmo is enabled, this can be used to track drag/end events
  41862. */
  41863. boundingBoxDragBehavior: SixDofDragBehavior;
  41864. /**
  41865. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  41866. */
  41867. attachableMeshes: Nullable<Array<AbstractMesh>>;
  41868. /**
  41869. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  41870. */
  41871. usePointerToAttachGizmos: boolean;
  41872. /**
  41873. * Instatiates a gizmo manager
  41874. * @param scene the scene to overlay the gizmos on top of
  41875. */
  41876. constructor(scene: Scene);
  41877. /**
  41878. * Attaches a set of gizmos to the specified mesh
  41879. * @param mesh The mesh the gizmo's should be attached to
  41880. */
  41881. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  41882. /**
  41883. * If the position gizmo is enabled
  41884. */
  41885. positionGizmoEnabled: boolean;
  41886. /**
  41887. * If the rotation gizmo is enabled
  41888. */
  41889. rotationGizmoEnabled: boolean;
  41890. /**
  41891. * If the scale gizmo is enabled
  41892. */
  41893. scaleGizmoEnabled: boolean;
  41894. /**
  41895. * If the boundingBox gizmo is enabled
  41896. */
  41897. boundingBoxGizmoEnabled: boolean;
  41898. /**
  41899. * Disposes of the gizmo manager
  41900. */
  41901. dispose(): void;
  41902. }
  41903. }
  41904. declare module BABYLON {
  41905. /**
  41906. * A directional light is defined by a direction (what a surprise!).
  41907. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  41908. * 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.
  41909. * Documentation: https://doc.babylonjs.com/babylon101/lights
  41910. */
  41911. export class DirectionalLight extends ShadowLight {
  41912. private _shadowFrustumSize;
  41913. /**
  41914. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  41915. */
  41916. /**
  41917. * Specifies a fix frustum size for the shadow generation.
  41918. */
  41919. shadowFrustumSize: number;
  41920. private _shadowOrthoScale;
  41921. /**
  41922. * Gets the shadow projection scale against the optimal computed one.
  41923. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  41924. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  41925. */
  41926. /**
  41927. * Sets the shadow projection scale against the optimal computed one.
  41928. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  41929. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  41930. */
  41931. shadowOrthoScale: number;
  41932. /**
  41933. * Automatically compute the projection matrix to best fit (including all the casters)
  41934. * on each frame.
  41935. */
  41936. autoUpdateExtends: boolean;
  41937. private _orthoLeft;
  41938. private _orthoRight;
  41939. private _orthoTop;
  41940. private _orthoBottom;
  41941. /**
  41942. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  41943. * The directional light is emitted from everywhere in the given direction.
  41944. * It can cast shadows.
  41945. * Documentation : https://doc.babylonjs.com/babylon101/lights
  41946. * @param name The friendly name of the light
  41947. * @param direction The direction of the light
  41948. * @param scene The scene the light belongs to
  41949. */
  41950. constructor(name: string, direction: Vector3, scene: Scene);
  41951. /**
  41952. * Returns the string "DirectionalLight".
  41953. * @return The class name
  41954. */
  41955. getClassName(): string;
  41956. /**
  41957. * Returns the integer 1.
  41958. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  41959. */
  41960. getTypeID(): number;
  41961. /**
  41962. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  41963. * Returns the DirectionalLight Shadow projection matrix.
  41964. */
  41965. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  41966. /**
  41967. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  41968. * Returns the DirectionalLight Shadow projection matrix.
  41969. */
  41970. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  41971. /**
  41972. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  41973. * Returns the DirectionalLight Shadow projection matrix.
  41974. */
  41975. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  41976. protected _buildUniformLayout(): void;
  41977. /**
  41978. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  41979. * @param effect The effect to update
  41980. * @param lightIndex The index of the light in the effect to update
  41981. * @returns The directional light
  41982. */
  41983. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  41984. /**
  41985. * Gets the minZ used for shadow according to both the scene and the light.
  41986. *
  41987. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  41988. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  41989. * @param activeCamera The camera we are returning the min for
  41990. * @returns the depth min z
  41991. */
  41992. getDepthMinZ(activeCamera: Camera): number;
  41993. /**
  41994. * Gets the maxZ used for shadow according to both the scene and the light.
  41995. *
  41996. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  41997. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  41998. * @param activeCamera The camera we are returning the max for
  41999. * @returns the depth max z
  42000. */
  42001. getDepthMaxZ(activeCamera: Camera): number;
  42002. /**
  42003. * Prepares the list of defines specific to the light type.
  42004. * @param defines the list of defines
  42005. * @param lightIndex defines the index of the light for the effect
  42006. */
  42007. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42008. }
  42009. }
  42010. declare module BABYLON {
  42011. /**
  42012. * Class containing static functions to help procedurally build meshes
  42013. */
  42014. export class HemisphereBuilder {
  42015. /**
  42016. * Creates a hemisphere mesh
  42017. * @param name defines the name of the mesh
  42018. * @param options defines the options used to create the mesh
  42019. * @param scene defines the hosting scene
  42020. * @returns the hemisphere mesh
  42021. */
  42022. static CreateHemisphere(name: string, options: {
  42023. segments?: number;
  42024. diameter?: number;
  42025. sideOrientation?: number;
  42026. }, scene: any): Mesh;
  42027. }
  42028. }
  42029. declare module BABYLON {
  42030. /**
  42031. * A spot light is defined by a position, a direction, an angle, and an exponent.
  42032. * These values define a cone of light starting from the position, emitting toward the direction.
  42033. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  42034. * and the exponent defines the speed of the decay of the light with distance (reach).
  42035. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42036. */
  42037. export class SpotLight extends ShadowLight {
  42038. private _angle;
  42039. private _innerAngle;
  42040. private _cosHalfAngle;
  42041. private _lightAngleScale;
  42042. private _lightAngleOffset;
  42043. /**
  42044. * Gets the cone angle of the spot light in Radians.
  42045. */
  42046. /**
  42047. * Sets the cone angle of the spot light in Radians.
  42048. */
  42049. angle: number;
  42050. /**
  42051. * Only used in gltf falloff mode, this defines the angle where
  42052. * the directional falloff will start before cutting at angle which could be seen
  42053. * as outer angle.
  42054. */
  42055. /**
  42056. * Only used in gltf falloff mode, this defines the angle where
  42057. * the directional falloff will start before cutting at angle which could be seen
  42058. * as outer angle.
  42059. */
  42060. innerAngle: number;
  42061. private _shadowAngleScale;
  42062. /**
  42063. * Allows scaling the angle of the light for shadow generation only.
  42064. */
  42065. /**
  42066. * Allows scaling the angle of the light for shadow generation only.
  42067. */
  42068. shadowAngleScale: number;
  42069. /**
  42070. * The light decay speed with the distance from the emission spot.
  42071. */
  42072. exponent: number;
  42073. private _projectionTextureMatrix;
  42074. /**
  42075. * Allows reading the projecton texture
  42076. */
  42077. readonly projectionTextureMatrix: Matrix;
  42078. protected _projectionTextureLightNear: number;
  42079. /**
  42080. * Gets the near clip of the Spotlight for texture projection.
  42081. */
  42082. /**
  42083. * Sets the near clip of the Spotlight for texture projection.
  42084. */
  42085. projectionTextureLightNear: number;
  42086. protected _projectionTextureLightFar: number;
  42087. /**
  42088. * Gets the far clip of the Spotlight for texture projection.
  42089. */
  42090. /**
  42091. * Sets the far clip of the Spotlight for texture projection.
  42092. */
  42093. projectionTextureLightFar: number;
  42094. protected _projectionTextureUpDirection: Vector3;
  42095. /**
  42096. * Gets the Up vector of the Spotlight for texture projection.
  42097. */
  42098. /**
  42099. * Sets the Up vector of the Spotlight for texture projection.
  42100. */
  42101. projectionTextureUpDirection: Vector3;
  42102. private _projectionTexture;
  42103. /**
  42104. * Gets the projection texture of the light.
  42105. */
  42106. /**
  42107. * Sets the projection texture of the light.
  42108. */
  42109. projectionTexture: Nullable<BaseTexture>;
  42110. private _projectionTextureViewLightDirty;
  42111. private _projectionTextureProjectionLightDirty;
  42112. private _projectionTextureDirty;
  42113. private _projectionTextureViewTargetVector;
  42114. private _projectionTextureViewLightMatrix;
  42115. private _projectionTextureProjectionLightMatrix;
  42116. private _projectionTextureScalingMatrix;
  42117. /**
  42118. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  42119. * It can cast shadows.
  42120. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42121. * @param name The light friendly name
  42122. * @param position The position of the spot light in the scene
  42123. * @param direction The direction of the light in the scene
  42124. * @param angle The cone angle of the light in Radians
  42125. * @param exponent The light decay speed with the distance from the emission spot
  42126. * @param scene The scene the lights belongs to
  42127. */
  42128. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  42129. /**
  42130. * Returns the string "SpotLight".
  42131. * @returns the class name
  42132. */
  42133. getClassName(): string;
  42134. /**
  42135. * Returns the integer 2.
  42136. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42137. */
  42138. getTypeID(): number;
  42139. /**
  42140. * Overrides the direction setter to recompute the projection texture view light Matrix.
  42141. */
  42142. protected _setDirection(value: Vector3): void;
  42143. /**
  42144. * Overrides the position setter to recompute the projection texture view light Matrix.
  42145. */
  42146. protected _setPosition(value: Vector3): void;
  42147. /**
  42148. * 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.
  42149. * Returns the SpotLight.
  42150. */
  42151. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42152. protected _computeProjectionTextureViewLightMatrix(): void;
  42153. protected _computeProjectionTextureProjectionLightMatrix(): void;
  42154. /**
  42155. * Main function for light texture projection matrix computing.
  42156. */
  42157. protected _computeProjectionTextureMatrix(): void;
  42158. protected _buildUniformLayout(): void;
  42159. private _computeAngleValues;
  42160. /**
  42161. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  42162. * @param effect The effect to update
  42163. * @param lightIndex The index of the light in the effect to update
  42164. * @returns The spot light
  42165. */
  42166. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  42167. /**
  42168. * Disposes the light and the associated resources.
  42169. */
  42170. dispose(): void;
  42171. /**
  42172. * Prepares the list of defines specific to the light type.
  42173. * @param defines the list of defines
  42174. * @param lightIndex defines the index of the light for the effect
  42175. */
  42176. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42177. }
  42178. }
  42179. declare module BABYLON {
  42180. /**
  42181. * Gizmo that enables viewing a light
  42182. */
  42183. export class LightGizmo extends Gizmo {
  42184. private _lightMesh;
  42185. private _material;
  42186. /**
  42187. * Creates a LightGizmo
  42188. * @param gizmoLayer The utility layer the gizmo will be added to
  42189. */
  42190. constructor(gizmoLayer?: UtilityLayerRenderer);
  42191. private _light;
  42192. /**
  42193. * The light that the gizmo is attached to
  42194. */
  42195. light: Nullable<Light>;
  42196. /**
  42197. * @hidden
  42198. * Updates the gizmo to match the attached mesh's position/rotation
  42199. */
  42200. protected _update(): void;
  42201. private static _Scale;
  42202. /**
  42203. * Creates the lines for a light mesh
  42204. */
  42205. private static _createLightLines;
  42206. private static _CreateHemisphericLightMesh;
  42207. private static _CreatePointLightMesh;
  42208. private static _CreateSpotLightMesh;
  42209. private static _CreateDirectionalLightMesh;
  42210. }
  42211. }
  42212. declare module BABYLON {
  42213. /** @hidden */
  42214. export var backgroundFragmentDeclaration: {
  42215. name: string;
  42216. shader: string;
  42217. };
  42218. }
  42219. declare module BABYLON {
  42220. /** @hidden */
  42221. export var backgroundUboDeclaration: {
  42222. name: string;
  42223. shader: string;
  42224. };
  42225. }
  42226. declare module BABYLON {
  42227. /** @hidden */
  42228. export var backgroundPixelShader: {
  42229. name: string;
  42230. shader: string;
  42231. };
  42232. }
  42233. declare module BABYLON {
  42234. /** @hidden */
  42235. export var backgroundVertexDeclaration: {
  42236. name: string;
  42237. shader: string;
  42238. };
  42239. }
  42240. declare module BABYLON {
  42241. /** @hidden */
  42242. export var backgroundVertexShader: {
  42243. name: string;
  42244. shader: string;
  42245. };
  42246. }
  42247. declare module BABYLON {
  42248. /**
  42249. * Background material used to create an efficient environement around your scene.
  42250. */
  42251. export class BackgroundMaterial extends PushMaterial {
  42252. /**
  42253. * Standard reflectance value at parallel view angle.
  42254. */
  42255. static StandardReflectance0: number;
  42256. /**
  42257. * Standard reflectance value at grazing angle.
  42258. */
  42259. static StandardReflectance90: number;
  42260. protected _primaryColor: Color3;
  42261. /**
  42262. * Key light Color (multiply against the environement texture)
  42263. */
  42264. primaryColor: Color3;
  42265. protected __perceptualColor: Nullable<Color3>;
  42266. /**
  42267. * Experimental Internal Use Only.
  42268. *
  42269. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42270. * This acts as a helper to set the primary color to a more "human friendly" value.
  42271. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42272. * output color as close as possible from the chosen value.
  42273. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42274. * part of lighting setup.)
  42275. */ perceptualColor: Nullable<Color3>;
  42276. protected _primaryColorShadowLevel: float;
  42277. /**
  42278. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42279. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42280. */
  42281. primaryColorShadowLevel: float;
  42282. protected _primaryColorHighlightLevel: float;
  42283. /**
  42284. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42285. * The primary color is used at the level chosen to define what the white area would look.
  42286. */
  42287. primaryColorHighlightLevel: float;
  42288. protected _reflectionTexture: Nullable<BaseTexture>;
  42289. /**
  42290. * Reflection Texture used in the material.
  42291. * Should be author in a specific way for the best result (refer to the documentation).
  42292. */
  42293. reflectionTexture: Nullable<BaseTexture>;
  42294. protected _reflectionBlur: float;
  42295. /**
  42296. * Reflection Texture level of blur.
  42297. *
  42298. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  42299. * texture twice.
  42300. */
  42301. reflectionBlur: float;
  42302. protected _diffuseTexture: Nullable<BaseTexture>;
  42303. /**
  42304. * Diffuse Texture used in the material.
  42305. * Should be author in a specific way for the best result (refer to the documentation).
  42306. */
  42307. diffuseTexture: Nullable<BaseTexture>;
  42308. protected _shadowLights: Nullable<IShadowLight[]>;
  42309. /**
  42310. * Specify the list of lights casting shadow on the material.
  42311. * All scene shadow lights will be included if null.
  42312. */
  42313. shadowLights: Nullable<IShadowLight[]>;
  42314. protected _shadowLevel: float;
  42315. /**
  42316. * Helps adjusting the shadow to a softer level if required.
  42317. * 0 means black shadows and 1 means no shadows.
  42318. */
  42319. shadowLevel: float;
  42320. protected _sceneCenter: Vector3;
  42321. /**
  42322. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  42323. * It is usually zero but might be interesting to modify according to your setup.
  42324. */
  42325. sceneCenter: Vector3;
  42326. protected _opacityFresnel: boolean;
  42327. /**
  42328. * This helps specifying that the material is falling off to the sky box at grazing angle.
  42329. * This helps ensuring a nice transition when the camera goes under the ground.
  42330. */
  42331. opacityFresnel: boolean;
  42332. protected _reflectionFresnel: boolean;
  42333. /**
  42334. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  42335. * This helps adding a mirror texture on the ground.
  42336. */
  42337. reflectionFresnel: boolean;
  42338. protected _reflectionFalloffDistance: number;
  42339. /**
  42340. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  42341. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  42342. */
  42343. reflectionFalloffDistance: number;
  42344. protected _reflectionAmount: number;
  42345. /**
  42346. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  42347. */
  42348. reflectionAmount: number;
  42349. protected _reflectionReflectance0: number;
  42350. /**
  42351. * This specifies the weight of the reflection at grazing angle.
  42352. */
  42353. reflectionReflectance0: number;
  42354. protected _reflectionReflectance90: number;
  42355. /**
  42356. * This specifies the weight of the reflection at a perpendicular point of view.
  42357. */
  42358. reflectionReflectance90: number;
  42359. /**
  42360. * Sets the reflection reflectance fresnel values according to the default standard
  42361. * empirically know to work well :-)
  42362. */
  42363. reflectionStandardFresnelWeight: number;
  42364. protected _useRGBColor: boolean;
  42365. /**
  42366. * Helps to directly use the maps channels instead of their level.
  42367. */
  42368. useRGBColor: boolean;
  42369. protected _enableNoise: boolean;
  42370. /**
  42371. * This helps reducing the banding effect that could occur on the background.
  42372. */
  42373. enableNoise: boolean;
  42374. /**
  42375. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42376. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  42377. * Recommended to be keep at 1.0 except for special cases.
  42378. */
  42379. fovMultiplier: number;
  42380. private _fovMultiplier;
  42381. /**
  42382. * Enable the FOV adjustment feature controlled by fovMultiplier.
  42383. */
  42384. useEquirectangularFOV: boolean;
  42385. private _maxSimultaneousLights;
  42386. /**
  42387. * Number of Simultaneous lights allowed on the material.
  42388. */
  42389. maxSimultaneousLights: int;
  42390. /**
  42391. * Default configuration related to image processing available in the Background Material.
  42392. */
  42393. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42394. /**
  42395. * Keep track of the image processing observer to allow dispose and replace.
  42396. */
  42397. private _imageProcessingObserver;
  42398. /**
  42399. * Attaches a new image processing configuration to the PBR Material.
  42400. * @param configuration (if null the scene configuration will be use)
  42401. */
  42402. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42403. /**
  42404. * Gets the image processing configuration used either in this material.
  42405. */
  42406. /**
  42407. * Sets the Default image processing configuration used either in the this material.
  42408. *
  42409. * If sets to null, the scene one is in use.
  42410. */
  42411. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  42412. /**
  42413. * Gets wether the color curves effect is enabled.
  42414. */
  42415. /**
  42416. * Sets wether the color curves effect is enabled.
  42417. */
  42418. cameraColorCurvesEnabled: boolean;
  42419. /**
  42420. * Gets wether the color grading effect is enabled.
  42421. */
  42422. /**
  42423. * Gets wether the color grading effect is enabled.
  42424. */
  42425. cameraColorGradingEnabled: boolean;
  42426. /**
  42427. * Gets wether tonemapping is enabled or not.
  42428. */
  42429. /**
  42430. * Sets wether tonemapping is enabled or not
  42431. */
  42432. cameraToneMappingEnabled: boolean;
  42433. /**
  42434. * The camera exposure used on this material.
  42435. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42436. * This corresponds to a photographic exposure.
  42437. */
  42438. /**
  42439. * The camera exposure used on this material.
  42440. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42441. * This corresponds to a photographic exposure.
  42442. */
  42443. cameraExposure: float;
  42444. /**
  42445. * Gets The camera contrast used on this material.
  42446. */
  42447. /**
  42448. * Sets The camera contrast used on this material.
  42449. */
  42450. cameraContrast: float;
  42451. /**
  42452. * Gets the Color Grading 2D Lookup Texture.
  42453. */
  42454. /**
  42455. * Sets the Color Grading 2D Lookup Texture.
  42456. */
  42457. cameraColorGradingTexture: Nullable<BaseTexture>;
  42458. /**
  42459. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42460. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42461. * 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;
  42462. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42463. */
  42464. /**
  42465. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42466. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42467. * 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;
  42468. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42469. */
  42470. cameraColorCurves: Nullable<ColorCurves>;
  42471. /**
  42472. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  42473. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  42474. */
  42475. switchToBGR: boolean;
  42476. private _renderTargets;
  42477. private _reflectionControls;
  42478. private _white;
  42479. private _primaryShadowColor;
  42480. private _primaryHighlightColor;
  42481. /**
  42482. * Instantiates a Background Material in the given scene
  42483. * @param name The friendly name of the material
  42484. * @param scene The scene to add the material to
  42485. */
  42486. constructor(name: string, scene: Scene);
  42487. /**
  42488. * Gets a boolean indicating that current material needs to register RTT
  42489. */
  42490. readonly hasRenderTargetTextures: boolean;
  42491. /**
  42492. * The entire material has been created in order to prevent overdraw.
  42493. * @returns false
  42494. */
  42495. needAlphaTesting(): boolean;
  42496. /**
  42497. * The entire material has been created in order to prevent overdraw.
  42498. * @returns true if blending is enable
  42499. */
  42500. needAlphaBlending(): boolean;
  42501. /**
  42502. * Checks wether the material is ready to be rendered for a given mesh.
  42503. * @param mesh The mesh to render
  42504. * @param subMesh The submesh to check against
  42505. * @param useInstances Specify wether or not the material is used with instances
  42506. * @returns true if all the dependencies are ready (Textures, Effects...)
  42507. */
  42508. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42509. /**
  42510. * Compute the primary color according to the chosen perceptual color.
  42511. */
  42512. private _computePrimaryColorFromPerceptualColor;
  42513. /**
  42514. * Compute the highlights and shadow colors according to their chosen levels.
  42515. */
  42516. private _computePrimaryColors;
  42517. /**
  42518. * Build the uniform buffer used in the material.
  42519. */
  42520. buildUniformLayout(): void;
  42521. /**
  42522. * Unbind the material.
  42523. */
  42524. unbind(): void;
  42525. /**
  42526. * Bind only the world matrix to the material.
  42527. * @param world The world matrix to bind.
  42528. */
  42529. bindOnlyWorldMatrix(world: Matrix): void;
  42530. /**
  42531. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  42532. * @param world The world matrix to bind.
  42533. * @param subMesh The submesh to bind for.
  42534. */
  42535. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42536. /**
  42537. * Dispose the material.
  42538. * @param forceDisposeEffect Force disposal of the associated effect.
  42539. * @param forceDisposeTextures Force disposal of the associated textures.
  42540. */
  42541. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42542. /**
  42543. * Clones the material.
  42544. * @param name The cloned name.
  42545. * @returns The cloned material.
  42546. */
  42547. clone(name: string): BackgroundMaterial;
  42548. /**
  42549. * Serializes the current material to its JSON representation.
  42550. * @returns The JSON representation.
  42551. */
  42552. serialize(): any;
  42553. /**
  42554. * Gets the class name of the material
  42555. * @returns "BackgroundMaterial"
  42556. */
  42557. getClassName(): string;
  42558. /**
  42559. * Parse a JSON input to create back a background material.
  42560. * @param source The JSON data to parse
  42561. * @param scene The scene to create the parsed material in
  42562. * @param rootUrl The root url of the assets the material depends upon
  42563. * @returns the instantiated BackgroundMaterial.
  42564. */
  42565. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  42566. }
  42567. }
  42568. declare module BABYLON {
  42569. /**
  42570. * Represents the different options available during the creation of
  42571. * a Environment helper.
  42572. *
  42573. * This can control the default ground, skybox and image processing setup of your scene.
  42574. */
  42575. export interface IEnvironmentHelperOptions {
  42576. /**
  42577. * Specifies wether or not to create a ground.
  42578. * True by default.
  42579. */
  42580. createGround: boolean;
  42581. /**
  42582. * Specifies the ground size.
  42583. * 15 by default.
  42584. */
  42585. groundSize: number;
  42586. /**
  42587. * The texture used on the ground for the main color.
  42588. * Comes from the BabylonJS CDN by default.
  42589. *
  42590. * Remarks: Can be either a texture or a url.
  42591. */
  42592. groundTexture: string | BaseTexture;
  42593. /**
  42594. * The color mixed in the ground texture by default.
  42595. * BabylonJS clearColor by default.
  42596. */
  42597. groundColor: Color3;
  42598. /**
  42599. * Specifies the ground opacity.
  42600. * 1 by default.
  42601. */
  42602. groundOpacity: number;
  42603. /**
  42604. * Enables the ground to receive shadows.
  42605. * True by default.
  42606. */
  42607. enableGroundShadow: boolean;
  42608. /**
  42609. * Helps preventing the shadow to be fully black on the ground.
  42610. * 0.5 by default.
  42611. */
  42612. groundShadowLevel: number;
  42613. /**
  42614. * Creates a mirror texture attach to the ground.
  42615. * false by default.
  42616. */
  42617. enableGroundMirror: boolean;
  42618. /**
  42619. * Specifies the ground mirror size ratio.
  42620. * 0.3 by default as the default kernel is 64.
  42621. */
  42622. groundMirrorSizeRatio: number;
  42623. /**
  42624. * Specifies the ground mirror blur kernel size.
  42625. * 64 by default.
  42626. */
  42627. groundMirrorBlurKernel: number;
  42628. /**
  42629. * Specifies the ground mirror visibility amount.
  42630. * 1 by default
  42631. */
  42632. groundMirrorAmount: number;
  42633. /**
  42634. * Specifies the ground mirror reflectance weight.
  42635. * This uses the standard weight of the background material to setup the fresnel effect
  42636. * of the mirror.
  42637. * 1 by default.
  42638. */
  42639. groundMirrorFresnelWeight: number;
  42640. /**
  42641. * Specifies the ground mirror Falloff distance.
  42642. * This can helps reducing the size of the reflection.
  42643. * 0 by Default.
  42644. */
  42645. groundMirrorFallOffDistance: number;
  42646. /**
  42647. * Specifies the ground mirror texture type.
  42648. * Unsigned Int by Default.
  42649. */
  42650. groundMirrorTextureType: number;
  42651. /**
  42652. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  42653. * the shown objects.
  42654. */
  42655. groundYBias: number;
  42656. /**
  42657. * Specifies wether or not to create a skybox.
  42658. * True by default.
  42659. */
  42660. createSkybox: boolean;
  42661. /**
  42662. * Specifies the skybox size.
  42663. * 20 by default.
  42664. */
  42665. skyboxSize: number;
  42666. /**
  42667. * The texture used on the skybox for the main color.
  42668. * Comes from the BabylonJS CDN by default.
  42669. *
  42670. * Remarks: Can be either a texture or a url.
  42671. */
  42672. skyboxTexture: string | BaseTexture;
  42673. /**
  42674. * The color mixed in the skybox texture by default.
  42675. * BabylonJS clearColor by default.
  42676. */
  42677. skyboxColor: Color3;
  42678. /**
  42679. * The background rotation around the Y axis of the scene.
  42680. * This helps aligning the key lights of your scene with the background.
  42681. * 0 by default.
  42682. */
  42683. backgroundYRotation: number;
  42684. /**
  42685. * Compute automatically the size of the elements to best fit with the scene.
  42686. */
  42687. sizeAuto: boolean;
  42688. /**
  42689. * Default position of the rootMesh if autoSize is not true.
  42690. */
  42691. rootPosition: Vector3;
  42692. /**
  42693. * Sets up the image processing in the scene.
  42694. * true by default.
  42695. */
  42696. setupImageProcessing: boolean;
  42697. /**
  42698. * The texture used as your environment texture in the scene.
  42699. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  42700. *
  42701. * Remarks: Can be either a texture or a url.
  42702. */
  42703. environmentTexture: string | BaseTexture;
  42704. /**
  42705. * The value of the exposure to apply to the scene.
  42706. * 0.6 by default if setupImageProcessing is true.
  42707. */
  42708. cameraExposure: number;
  42709. /**
  42710. * The value of the contrast to apply to the scene.
  42711. * 1.6 by default if setupImageProcessing is true.
  42712. */
  42713. cameraContrast: number;
  42714. /**
  42715. * Specifies wether or not tonemapping should be enabled in the scene.
  42716. * true by default if setupImageProcessing is true.
  42717. */
  42718. toneMappingEnabled: boolean;
  42719. }
  42720. /**
  42721. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  42722. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  42723. * It also helps with the default setup of your imageProcessing configuration.
  42724. */
  42725. export class EnvironmentHelper {
  42726. /**
  42727. * Default ground texture URL.
  42728. */
  42729. private static _groundTextureCDNUrl;
  42730. /**
  42731. * Default skybox texture URL.
  42732. */
  42733. private static _skyboxTextureCDNUrl;
  42734. /**
  42735. * Default environment texture URL.
  42736. */
  42737. private static _environmentTextureCDNUrl;
  42738. /**
  42739. * Creates the default options for the helper.
  42740. */
  42741. private static _getDefaultOptions;
  42742. private _rootMesh;
  42743. /**
  42744. * Gets the root mesh created by the helper.
  42745. */
  42746. readonly rootMesh: Mesh;
  42747. private _skybox;
  42748. /**
  42749. * Gets the skybox created by the helper.
  42750. */
  42751. readonly skybox: Nullable<Mesh>;
  42752. private _skyboxTexture;
  42753. /**
  42754. * Gets the skybox texture created by the helper.
  42755. */
  42756. readonly skyboxTexture: Nullable<BaseTexture>;
  42757. private _skyboxMaterial;
  42758. /**
  42759. * Gets the skybox material created by the helper.
  42760. */
  42761. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  42762. private _ground;
  42763. /**
  42764. * Gets the ground mesh created by the helper.
  42765. */
  42766. readonly ground: Nullable<Mesh>;
  42767. private _groundTexture;
  42768. /**
  42769. * Gets the ground texture created by the helper.
  42770. */
  42771. readonly groundTexture: Nullable<BaseTexture>;
  42772. private _groundMirror;
  42773. /**
  42774. * Gets the ground mirror created by the helper.
  42775. */
  42776. readonly groundMirror: Nullable<MirrorTexture>;
  42777. /**
  42778. * Gets the ground mirror render list to helps pushing the meshes
  42779. * you wish in the ground reflection.
  42780. */
  42781. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  42782. private _groundMaterial;
  42783. /**
  42784. * Gets the ground material created by the helper.
  42785. */
  42786. readonly groundMaterial: Nullable<BackgroundMaterial>;
  42787. /**
  42788. * Stores the creation options.
  42789. */
  42790. private readonly _scene;
  42791. private _options;
  42792. /**
  42793. * This observable will be notified with any error during the creation of the environment,
  42794. * mainly texture creation errors.
  42795. */
  42796. onErrorObservable: Observable<{
  42797. message?: string;
  42798. exception?: any;
  42799. }>;
  42800. /**
  42801. * constructor
  42802. * @param options Defines the options we want to customize the helper
  42803. * @param scene The scene to add the material to
  42804. */
  42805. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  42806. /**
  42807. * Updates the background according to the new options
  42808. * @param options
  42809. */
  42810. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  42811. /**
  42812. * Sets the primary color of all the available elements.
  42813. * @param color the main color to affect to the ground and the background
  42814. */
  42815. setMainColor(color: Color3): void;
  42816. /**
  42817. * Setup the image processing according to the specified options.
  42818. */
  42819. private _setupImageProcessing;
  42820. /**
  42821. * Setup the environment texture according to the specified options.
  42822. */
  42823. private _setupEnvironmentTexture;
  42824. /**
  42825. * Setup the background according to the specified options.
  42826. */
  42827. private _setupBackground;
  42828. /**
  42829. * Get the scene sizes according to the setup.
  42830. */
  42831. private _getSceneSize;
  42832. /**
  42833. * Setup the ground according to the specified options.
  42834. */
  42835. private _setupGround;
  42836. /**
  42837. * Setup the ground material according to the specified options.
  42838. */
  42839. private _setupGroundMaterial;
  42840. /**
  42841. * Setup the ground diffuse texture according to the specified options.
  42842. */
  42843. private _setupGroundDiffuseTexture;
  42844. /**
  42845. * Setup the ground mirror texture according to the specified options.
  42846. */
  42847. private _setupGroundMirrorTexture;
  42848. /**
  42849. * Setup the ground to receive the mirror texture.
  42850. */
  42851. private _setupMirrorInGroundMaterial;
  42852. /**
  42853. * Setup the skybox according to the specified options.
  42854. */
  42855. private _setupSkybox;
  42856. /**
  42857. * Setup the skybox material according to the specified options.
  42858. */
  42859. private _setupSkyboxMaterial;
  42860. /**
  42861. * Setup the skybox reflection texture according to the specified options.
  42862. */
  42863. private _setupSkyboxReflectionTexture;
  42864. private _errorHandler;
  42865. /**
  42866. * Dispose all the elements created by the Helper.
  42867. */
  42868. dispose(): void;
  42869. }
  42870. }
  42871. declare module BABYLON {
  42872. /**
  42873. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  42874. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  42875. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  42876. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  42877. */
  42878. export class PhotoDome extends TransformNode {
  42879. private _useDirectMapping;
  42880. /**
  42881. * The texture being displayed on the sphere
  42882. */
  42883. protected _photoTexture: Texture;
  42884. /**
  42885. * Gets or sets the texture being displayed on the sphere
  42886. */
  42887. photoTexture: Texture;
  42888. /**
  42889. * Observable raised when an error occured while loading the 360 image
  42890. */
  42891. onLoadErrorObservable: Observable<string>;
  42892. /**
  42893. * The skybox material
  42894. */
  42895. protected _material: BackgroundMaterial;
  42896. /**
  42897. * The surface used for the skybox
  42898. */
  42899. protected _mesh: Mesh;
  42900. /**
  42901. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42902. * Also see the options.resolution property.
  42903. */
  42904. fovMultiplier: number;
  42905. /**
  42906. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  42907. * @param name Element's name, child elements will append suffixes for their own names.
  42908. * @param urlsOfPhoto defines the url of the photo to display
  42909. * @param options defines an object containing optional or exposed sub element properties
  42910. * @param onError defines a callback called when an error occured while loading the texture
  42911. */
  42912. constructor(name: string, urlOfPhoto: string, options: {
  42913. resolution?: number;
  42914. size?: number;
  42915. useDirectMapping?: boolean;
  42916. faceForward?: boolean;
  42917. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  42918. /**
  42919. * Releases resources associated with this node.
  42920. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  42921. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  42922. */
  42923. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  42924. }
  42925. }
  42926. declare module BABYLON {
  42927. /** @hidden */
  42928. export var rgbdDecodePixelShader: {
  42929. name: string;
  42930. shader: string;
  42931. };
  42932. }
  42933. declare module BABYLON {
  42934. /**
  42935. * Class used to host texture specific utilities
  42936. */
  42937. export class BRDFTextureTools {
  42938. /**
  42939. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  42940. * @param texture the texture to expand.
  42941. */
  42942. private static _ExpandDefaultBRDFTexture;
  42943. /**
  42944. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  42945. * @param scene defines the hosting scene
  42946. * @returns the environment BRDF texture
  42947. */
  42948. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  42949. private static _environmentBRDFBase64Texture;
  42950. }
  42951. }
  42952. declare module BABYLON {
  42953. /**
  42954. * @hidden
  42955. */
  42956. export interface IMaterialClearCoatDefines {
  42957. CLEARCOAT: boolean;
  42958. CLEARCOAT_DEFAULTIOR: boolean;
  42959. CLEARCOAT_TEXTURE: boolean;
  42960. CLEARCOAT_TEXTUREDIRECTUV: number;
  42961. CLEARCOAT_BUMP: boolean;
  42962. CLEARCOAT_BUMPDIRECTUV: number;
  42963. CLEARCOAT_TINT: boolean;
  42964. CLEARCOAT_TINT_TEXTURE: boolean;
  42965. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  42966. /** @hidden */ areTexturesDirty: boolean;
  42967. }
  42968. /**
  42969. * Define the code related to the clear coat parameters of the pbr material.
  42970. */
  42971. export class PBRClearCoatConfiguration {
  42972. /**
  42973. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  42974. * The default fits with a polyurethane material.
  42975. */
  42976. private static readonly _DefaultIndiceOfRefraction;
  42977. private _isEnabled;
  42978. /**
  42979. * Defines if the clear coat is enabled in the material.
  42980. */
  42981. isEnabled: boolean;
  42982. /**
  42983. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  42984. */
  42985. intensity: number;
  42986. /**
  42987. * Defines the clear coat layer roughness.
  42988. */
  42989. roughness: number;
  42990. private _indiceOfRefraction;
  42991. /**
  42992. * Defines the indice of refraction of the clear coat.
  42993. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  42994. * The default fits with a polyurethane material.
  42995. * Changing the default value is more performance intensive.
  42996. */
  42997. indiceOfRefraction: number;
  42998. private _texture;
  42999. /**
  43000. * Stores the clear coat values in a texture.
  43001. */
  43002. texture: Nullable<BaseTexture>;
  43003. private _bumpTexture;
  43004. /**
  43005. * Define the clear coat specific bump texture.
  43006. */
  43007. bumpTexture: Nullable<BaseTexture>;
  43008. private _isTintEnabled;
  43009. /**
  43010. * Defines if the clear coat tint is enabled in the material.
  43011. */
  43012. isTintEnabled: boolean;
  43013. /**
  43014. * Defines the clear coat tint of the material.
  43015. * This is only use if tint is enabled
  43016. */
  43017. tintColor: Color3;
  43018. /**
  43019. * Defines the distance at which the tint color should be found in the
  43020. * clear coat media.
  43021. * This is only use if tint is enabled
  43022. */
  43023. tintColorAtDistance: number;
  43024. /**
  43025. * Defines the clear coat layer thickness.
  43026. * This is only use if tint is enabled
  43027. */
  43028. tintThickness: number;
  43029. private _tintTexture;
  43030. /**
  43031. * Stores the clear tint values in a texture.
  43032. * rgb is tint
  43033. * a is a thickness factor
  43034. */
  43035. tintTexture: Nullable<BaseTexture>;
  43036. /** @hidden */
  43037. private _internalMarkAllSubMeshesAsTexturesDirty;
  43038. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43039. /**
  43040. * Instantiate a new istance of clear coat configuration.
  43041. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43042. */
  43043. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43044. /**
  43045. * Gets wehter the submesh is ready to be used or not.
  43046. * @param defines the list of "defines" to update.
  43047. * @param scene defines the scene the material belongs to.
  43048. * @param engine defines the engine the material belongs to.
  43049. * @param disableBumpMap defines wether the material disables bump or not.
  43050. * @returns - boolean indicating that the submesh is ready or not.
  43051. */
  43052. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43053. /**
  43054. * Checks to see if a texture is used in the material.
  43055. * @param defines the list of "defines" to update.
  43056. * @param scene defines the scene to the material belongs to.
  43057. */
  43058. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43059. /**
  43060. * Binds the material data.
  43061. * @param uniformBuffer defines the Uniform buffer to fill in.
  43062. * @param scene defines the scene the material belongs to.
  43063. * @param engine defines the engine the material belongs to.
  43064. * @param disableBumpMap defines wether the material disables bump or not.
  43065. * @param isFrozen defines wether the material is frozen or not.
  43066. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43067. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43068. */
  43069. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43070. /**
  43071. * Checks to see if a texture is used in the material.
  43072. * @param texture - Base texture to use.
  43073. * @returns - Boolean specifying if a texture is used in the material.
  43074. */
  43075. hasTexture(texture: BaseTexture): boolean;
  43076. /**
  43077. * Returns an array of the actively used textures.
  43078. * @param activeTextures Array of BaseTextures
  43079. */
  43080. getActiveTextures(activeTextures: BaseTexture[]): void;
  43081. /**
  43082. * Returns the animatable textures.
  43083. * @param animatables Array of animatable textures.
  43084. */
  43085. getAnimatables(animatables: IAnimatable[]): void;
  43086. /**
  43087. * Disposes the resources of the material.
  43088. * @param forceDisposeTextures - Forces the disposal of all textures.
  43089. */
  43090. dispose(forceDisposeTextures?: boolean): void;
  43091. /**
  43092. * Get the current class name of the texture useful for serialization or dynamic coding.
  43093. * @returns "PBRClearCoatConfiguration"
  43094. */
  43095. getClassName(): string;
  43096. /**
  43097. * Add fallbacks to the effect fallbacks list.
  43098. * @param defines defines the Base texture to use.
  43099. * @param fallbacks defines the current fallback list.
  43100. * @param currentRank defines the current fallback rank.
  43101. * @returns the new fallback rank.
  43102. */
  43103. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43104. /**
  43105. * Add the required uniforms to the current list.
  43106. * @param uniforms defines the current uniform list.
  43107. */
  43108. static AddUniforms(uniforms: string[]): void;
  43109. /**
  43110. * Add the required samplers to the current list.
  43111. * @param samplers defines the current sampler list.
  43112. */
  43113. static AddSamplers(samplers: string[]): void;
  43114. /**
  43115. * Add the required uniforms to the current buffer.
  43116. * @param uniformBuffer defines the current uniform buffer.
  43117. */
  43118. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43119. /**
  43120. * Makes a duplicate of the current configuration into another one.
  43121. * @param clearCoatConfiguration define the config where to copy the info
  43122. */
  43123. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  43124. /**
  43125. * Serializes this clear coat configuration.
  43126. * @returns - An object with the serialized config.
  43127. */
  43128. serialize(): any;
  43129. /**
  43130. * Parses a Clear Coat Configuration from a serialized object.
  43131. * @param source - Serialized object.
  43132. */
  43133. parse(source: any): void;
  43134. }
  43135. }
  43136. declare module BABYLON {
  43137. /**
  43138. * @hidden
  43139. */
  43140. export interface IMaterialAnisotropicDefines {
  43141. ANISOTROPIC: boolean;
  43142. ANISOTROPIC_TEXTURE: boolean;
  43143. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43144. MAINUV1: boolean; areTexturesDirty: boolean; needUVs: boolean;
  43145. }
  43146. /**
  43147. * Define the code related to the anisotropic parameters of the pbr material.
  43148. */
  43149. export class PBRAnisotropicConfiguration {
  43150. private _isEnabled;
  43151. /**
  43152. * Defines if the anisotropy is enabled in the material.
  43153. */
  43154. isEnabled: boolean;
  43155. /**
  43156. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  43157. */
  43158. intensity: number;
  43159. /**
  43160. * Defines if the effect is along the tangents, bitangents or in between.
  43161. * By default, the effect is "strectching" the highlights along the tangents.
  43162. */
  43163. direction: Vector2;
  43164. private _texture;
  43165. /**
  43166. * Stores the anisotropy values in a texture.
  43167. * rg is direction (like normal from -1 to 1)
  43168. * b is a intensity
  43169. */
  43170. texture: Nullable<BaseTexture>;
  43171. /** @hidden */
  43172. private _internalMarkAllSubMeshesAsTexturesDirty;
  43173. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43174. /**
  43175. * Instantiate a new istance of anisotropy configuration.
  43176. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43177. */
  43178. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43179. /**
  43180. * Specifies that the submesh is ready to be used.
  43181. * @param defines the list of "defines" to update.
  43182. * @param scene defines the scene the material belongs to.
  43183. * @returns - boolean indicating that the submesh is ready or not.
  43184. */
  43185. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  43186. /**
  43187. * Checks to see if a texture is used in the material.
  43188. * @param defines the list of "defines" to update.
  43189. * @param mesh the mesh we are preparing the defines for.
  43190. * @param scene defines the scene the material belongs to.
  43191. */
  43192. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  43193. /**
  43194. * Binds the material data.
  43195. * @param uniformBuffer defines the Uniform buffer to fill in.
  43196. * @param scene defines the scene the material belongs to.
  43197. * @param isFrozen defines wether the material is frozen or not.
  43198. */
  43199. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43200. /**
  43201. * Checks to see if a texture is used in the material.
  43202. * @param texture - Base texture to use.
  43203. * @returns - Boolean specifying if a texture is used in the material.
  43204. */
  43205. hasTexture(texture: BaseTexture): boolean;
  43206. /**
  43207. * Returns an array of the actively used textures.
  43208. * @param activeTextures Array of BaseTextures
  43209. */
  43210. getActiveTextures(activeTextures: BaseTexture[]): void;
  43211. /**
  43212. * Returns the animatable textures.
  43213. * @param animatables Array of animatable textures.
  43214. */
  43215. getAnimatables(animatables: IAnimatable[]): void;
  43216. /**
  43217. * Disposes the resources of the material.
  43218. * @param forceDisposeTextures - Forces the disposal of all textures.
  43219. */
  43220. dispose(forceDisposeTextures?: boolean): void;
  43221. /**
  43222. * Get the current class name of the texture useful for serialization or dynamic coding.
  43223. * @returns "PBRAnisotropicConfiguration"
  43224. */
  43225. getClassName(): string;
  43226. /**
  43227. * Add fallbacks to the effect fallbacks list.
  43228. * @param defines defines the Base texture to use.
  43229. * @param fallbacks defines the current fallback list.
  43230. * @param currentRank defines the current fallback rank.
  43231. * @returns the new fallback rank.
  43232. */
  43233. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43234. /**
  43235. * Add the required uniforms to the current list.
  43236. * @param uniforms defines the current uniform list.
  43237. */
  43238. static AddUniforms(uniforms: string[]): void;
  43239. /**
  43240. * Add the required uniforms to the current buffer.
  43241. * @param uniformBuffer defines the current uniform buffer.
  43242. */
  43243. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43244. /**
  43245. * Add the required samplers to the current list.
  43246. * @param samplers defines the current sampler list.
  43247. */
  43248. static AddSamplers(samplers: string[]): void;
  43249. /**
  43250. * Makes a duplicate of the current configuration into another one.
  43251. * @param anisotropicConfiguration define the config where to copy the info
  43252. */
  43253. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  43254. /**
  43255. * Serializes this anisotropy configuration.
  43256. * @returns - An object with the serialized config.
  43257. */
  43258. serialize(): any;
  43259. /**
  43260. * Parses a anisotropy Configuration from a serialized object.
  43261. * @param source - Serialized object.
  43262. */
  43263. parse(source: any): void;
  43264. }
  43265. }
  43266. declare module BABYLON {
  43267. /**
  43268. * @hidden
  43269. */
  43270. export interface IMaterialBRDFDefines {
  43271. BRDF_V_HEIGHT_CORRELATED: boolean;
  43272. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43273. /** @hidden */ areMiscDirty: boolean;
  43274. }
  43275. /**
  43276. * Define the code related to the BRDF parameters of the pbr material.
  43277. */
  43278. export class PBRBRDFConfiguration {
  43279. /**
  43280. * Default value used for the energy conservation.
  43281. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43282. */
  43283. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  43284. /**
  43285. * Default value used for the Smith Visibility Height Correlated mode.
  43286. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43287. */
  43288. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  43289. private _useEnergyConservation;
  43290. /**
  43291. * Defines if the material uses energy conservation.
  43292. */
  43293. useEnergyConservation: boolean;
  43294. private _useSmithVisibilityHeightCorrelated;
  43295. /**
  43296. * LEGACY Mode set to false
  43297. * Defines if the material uses height smith correlated visibility term.
  43298. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  43299. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  43300. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  43301. * Not relying on height correlated will also disable energy conservation.
  43302. */
  43303. useSmithVisibilityHeightCorrelated: boolean;
  43304. /** @hidden */
  43305. private _internalMarkAllSubMeshesAsMiscDirty;
  43306. /** @hidden */ markAllSubMeshesAsMiscDirty(): void;
  43307. /**
  43308. * Instantiate a new istance of clear coat configuration.
  43309. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  43310. */
  43311. constructor(markAllSubMeshesAsMiscDirty: () => void);
  43312. /**
  43313. * Checks to see if a texture is used in the material.
  43314. * @param defines the list of "defines" to update.
  43315. */
  43316. prepareDefines(defines: IMaterialBRDFDefines): void;
  43317. /**
  43318. * Get the current class name of the texture useful for serialization or dynamic coding.
  43319. * @returns "PBRClearCoatConfiguration"
  43320. */
  43321. getClassName(): string;
  43322. /**
  43323. * Makes a duplicate of the current configuration into another one.
  43324. * @param brdfConfiguration define the config where to copy the info
  43325. */
  43326. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  43327. /**
  43328. * Serializes this BRDF configuration.
  43329. * @returns - An object with the serialized config.
  43330. */
  43331. serialize(): any;
  43332. /**
  43333. * Parses a BRDF Configuration from a serialized object.
  43334. * @param source - Serialized object.
  43335. */
  43336. parse(source: any): void;
  43337. }
  43338. }
  43339. declare module BABYLON {
  43340. /**
  43341. * @hidden
  43342. */
  43343. export interface IMaterialSheenDefines {
  43344. SHEEN: boolean;
  43345. SHEEN_TEXTURE: boolean;
  43346. SHEEN_TEXTUREDIRECTUV: number;
  43347. SHEEN_LINKWITHALBEDO: boolean;
  43348. /** @hidden */ areTexturesDirty: boolean;
  43349. }
  43350. /**
  43351. * Define the code related to the Sheen parameters of the pbr material.
  43352. */
  43353. export class PBRSheenConfiguration {
  43354. private _isEnabled;
  43355. /**
  43356. * Defines if the material uses sheen.
  43357. */
  43358. isEnabled: boolean;
  43359. private _linkSheenWithAlbedo;
  43360. /**
  43361. * Defines if the sheen is linked to the sheen color.
  43362. */
  43363. linkSheenWithAlbedo: boolean;
  43364. /**
  43365. * Defines the sheen intensity.
  43366. */
  43367. intensity: number;
  43368. /**
  43369. * Defines the sheen color.
  43370. */
  43371. color: Color3;
  43372. private _texture;
  43373. /**
  43374. * Stores the sheen tint values in a texture.
  43375. * rgb is tint
  43376. * a is a intensity
  43377. */
  43378. texture: Nullable<BaseTexture>;
  43379. /** @hidden */
  43380. private _internalMarkAllSubMeshesAsTexturesDirty;
  43381. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43382. /**
  43383. * Instantiate a new istance of clear coat configuration.
  43384. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43385. */
  43386. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43387. /**
  43388. * Specifies that the submesh is ready to be used.
  43389. * @param defines the list of "defines" to update.
  43390. * @param scene defines the scene the material belongs to.
  43391. * @returns - boolean indicating that the submesh is ready or not.
  43392. */
  43393. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  43394. /**
  43395. * Checks to see if a texture is used in the material.
  43396. * @param defines the list of "defines" to update.
  43397. * @param scene defines the scene the material belongs to.
  43398. */
  43399. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  43400. /**
  43401. * Binds the material data.
  43402. * @param uniformBuffer defines the Uniform buffer to fill in.
  43403. * @param scene defines the scene the material belongs to.
  43404. * @param isFrozen defines wether the material is frozen or not.
  43405. */
  43406. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43407. /**
  43408. * Checks to see if a texture is used in the material.
  43409. * @param texture - Base texture to use.
  43410. * @returns - Boolean specifying if a texture is used in the material.
  43411. */
  43412. hasTexture(texture: BaseTexture): boolean;
  43413. /**
  43414. * Returns an array of the actively used textures.
  43415. * @param activeTextures Array of BaseTextures
  43416. */
  43417. getActiveTextures(activeTextures: BaseTexture[]): void;
  43418. /**
  43419. * Returns the animatable textures.
  43420. * @param animatables Array of animatable textures.
  43421. */
  43422. getAnimatables(animatables: IAnimatable[]): void;
  43423. /**
  43424. * Disposes the resources of the material.
  43425. * @param forceDisposeTextures - Forces the disposal of all textures.
  43426. */
  43427. dispose(forceDisposeTextures?: boolean): void;
  43428. /**
  43429. * Get the current class name of the texture useful for serialization or dynamic coding.
  43430. * @returns "PBRSheenConfiguration"
  43431. */
  43432. getClassName(): string;
  43433. /**
  43434. * Add fallbacks to the effect fallbacks list.
  43435. * @param defines defines the Base texture to use.
  43436. * @param fallbacks defines the current fallback list.
  43437. * @param currentRank defines the current fallback rank.
  43438. * @returns the new fallback rank.
  43439. */
  43440. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43441. /**
  43442. * Add the required uniforms to the current list.
  43443. * @param uniforms defines the current uniform list.
  43444. */
  43445. static AddUniforms(uniforms: string[]): void;
  43446. /**
  43447. * Add the required uniforms to the current buffer.
  43448. * @param uniformBuffer defines the current uniform buffer.
  43449. */
  43450. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43451. /**
  43452. * Add the required samplers to the current list.
  43453. * @param samplers defines the current sampler list.
  43454. */
  43455. static AddSamplers(samplers: string[]): void;
  43456. /**
  43457. * Makes a duplicate of the current configuration into another one.
  43458. * @param sheenConfiguration define the config where to copy the info
  43459. */
  43460. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  43461. /**
  43462. * Serializes this BRDF configuration.
  43463. * @returns - An object with the serialized config.
  43464. */
  43465. serialize(): any;
  43466. /**
  43467. * Parses a Sheen Configuration from a serialized object.
  43468. * @param source - Serialized object.
  43469. */
  43470. parse(source: any): void;
  43471. }
  43472. }
  43473. declare module BABYLON {
  43474. /**
  43475. * @hidden
  43476. */
  43477. export interface IMaterialSubSurfaceDefines {
  43478. SUBSURFACE: boolean;
  43479. SS_REFRACTION: boolean;
  43480. SS_TRANSLUCENCY: boolean;
  43481. SS_SCATERRING: boolean;
  43482. SS_THICKNESSANDMASK_TEXTURE: boolean;
  43483. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  43484. SS_REFRACTIONMAP_3D: boolean;
  43485. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  43486. SS_LODINREFRACTIONALPHA: boolean;
  43487. SS_GAMMAREFRACTION: boolean;
  43488. SS_RGBDREFRACTION: boolean;
  43489. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  43490. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  43491. /** @hidden */ areTexturesDirty: boolean;
  43492. }
  43493. /**
  43494. * Define the code related to the sub surface parameters of the pbr material.
  43495. */
  43496. export class PBRSubSurfaceConfiguration {
  43497. private _isRefractionEnabled;
  43498. /**
  43499. * Defines if the refraction is enabled in the material.
  43500. */
  43501. isRefractionEnabled: boolean;
  43502. private _isTranslucencyEnabled;
  43503. /**
  43504. * Defines if the translucency is enabled in the material.
  43505. */
  43506. isTranslucencyEnabled: boolean;
  43507. private _isScatteringEnabled;
  43508. /**
  43509. * Defines the refraction intensity of the material.
  43510. * The refraction when enabled replaces the Diffuse part of the material.
  43511. * The intensity helps transitionning between diffuse and refraction.
  43512. */
  43513. refractionIntensity: number;
  43514. /**
  43515. * Defines the translucency intensity of the material.
  43516. * When translucency has been enabled, this defines how much of the "translucency"
  43517. * is addded to the diffuse part of the material.
  43518. */
  43519. translucencyIntensity: number;
  43520. /**
  43521. * Defines the scattering intensity of the material.
  43522. * When scattering has been enabled, this defines how much of the "scattered light"
  43523. * is addded to the diffuse part of the material.
  43524. */
  43525. scatteringIntensity: number;
  43526. private _thicknessTexture;
  43527. /**
  43528. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  43529. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  43530. * 0 would mean minimumThickness
  43531. * 1 would mean maximumThickness
  43532. * The other channels might be use as a mask to vary the different effects intensity.
  43533. */
  43534. thicknessTexture: Nullable<BaseTexture>;
  43535. private _refractionTexture;
  43536. /**
  43537. * Defines the texture to use for refraction.
  43538. */
  43539. refractionTexture: Nullable<BaseTexture>;
  43540. private _indexOfRefraction;
  43541. /**
  43542. * Defines the indice of refraction used in the material.
  43543. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  43544. */
  43545. indexOfRefraction: number;
  43546. private _invertRefractionY;
  43547. /**
  43548. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  43549. */
  43550. invertRefractionY: boolean;
  43551. private _linkRefractionWithTransparency;
  43552. /**
  43553. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43554. * Materials half opaque for instance using refraction could benefit from this control.
  43555. */
  43556. linkRefractionWithTransparency: boolean;
  43557. /**
  43558. * Defines the minimum thickness stored in the thickness map.
  43559. * If no thickness map is defined, this value will be used to simulate thickness.
  43560. */
  43561. minimumThickness: number;
  43562. /**
  43563. * Defines the maximum thickness stored in the thickness map.
  43564. */
  43565. maximumThickness: number;
  43566. /**
  43567. * Defines the volume tint of the material.
  43568. * This is used for both translucency and scattering.
  43569. */
  43570. tintColor: Color3;
  43571. /**
  43572. * Defines the distance at which the tint color should be found in the media.
  43573. * This is used for refraction only.
  43574. */
  43575. tintColorAtDistance: number;
  43576. /**
  43577. * Defines how far each channel transmit through the media.
  43578. * It is defined as a color to simplify it selection.
  43579. */
  43580. diffusionDistance: Color3;
  43581. private _useMaskFromThicknessTexture;
  43582. /**
  43583. * Stores the intensity of the different subsurface effects in the thickness texture.
  43584. * * the green channel is the translucency intensity.
  43585. * * the blue channel is the scattering intensity.
  43586. * * the alpha channel is the refraction intensity.
  43587. */
  43588. useMaskFromThicknessTexture: boolean;
  43589. /** @hidden */
  43590. private _internalMarkAllSubMeshesAsTexturesDirty;
  43591. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43592. /**
  43593. * Instantiate a new istance of sub surface configuration.
  43594. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43595. */
  43596. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43597. /**
  43598. * Gets wehter the submesh is ready to be used or not.
  43599. * @param defines the list of "defines" to update.
  43600. * @param scene defines the scene the material belongs to.
  43601. * @returns - boolean indicating that the submesh is ready or not.
  43602. */
  43603. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  43604. /**
  43605. * Checks to see if a texture is used in the material.
  43606. * @param defines the list of "defines" to update.
  43607. * @param scene defines the scene to the material belongs to.
  43608. */
  43609. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  43610. /**
  43611. * Binds the material data.
  43612. * @param uniformBuffer defines the Uniform buffer to fill in.
  43613. * @param scene defines the scene the material belongs to.
  43614. * @param engine defines the engine the material belongs to.
  43615. * @param isFrozen defines wether the material is frozen or not.
  43616. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  43617. */
  43618. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  43619. /**
  43620. * Unbinds the material from the mesh.
  43621. * @param activeEffect defines the effect that should be unbound from.
  43622. * @returns true if unbound, otherwise false
  43623. */
  43624. unbind(activeEffect: Effect): boolean;
  43625. /**
  43626. * Returns the texture used for refraction or null if none is used.
  43627. * @param scene defines the scene the material belongs to.
  43628. * @returns - Refraction texture if present. If no refraction texture and refraction
  43629. * is linked with transparency, returns environment texture. Otherwise, returns null.
  43630. */
  43631. private _getRefractionTexture;
  43632. /**
  43633. * Returns true if alpha blending should be disabled.
  43634. */
  43635. readonly disableAlphaBlending: boolean;
  43636. /**
  43637. * Fills the list of render target textures.
  43638. * @param renderTargets the list of render targets to update
  43639. */
  43640. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  43641. /**
  43642. * Checks to see if a texture is used in the material.
  43643. * @param texture - Base texture to use.
  43644. * @returns - Boolean specifying if a texture is used in the material.
  43645. */
  43646. hasTexture(texture: BaseTexture): boolean;
  43647. /**
  43648. * Gets a boolean indicating that current material needs to register RTT
  43649. * @returns true if this uses a render target otherwise false.
  43650. */
  43651. hasRenderTargetTextures(): boolean;
  43652. /**
  43653. * Returns an array of the actively used textures.
  43654. * @param activeTextures Array of BaseTextures
  43655. */
  43656. getActiveTextures(activeTextures: BaseTexture[]): void;
  43657. /**
  43658. * Returns the animatable textures.
  43659. * @param animatables Array of animatable textures.
  43660. */
  43661. getAnimatables(animatables: IAnimatable[]): void;
  43662. /**
  43663. * Disposes the resources of the material.
  43664. * @param forceDisposeTextures - Forces the disposal of all textures.
  43665. */
  43666. dispose(forceDisposeTextures?: boolean): void;
  43667. /**
  43668. * Get the current class name of the texture useful for serialization or dynamic coding.
  43669. * @returns "PBRSubSurfaceConfiguration"
  43670. */
  43671. getClassName(): string;
  43672. /**
  43673. * Add fallbacks to the effect fallbacks list.
  43674. * @param defines defines the Base texture to use.
  43675. * @param fallbacks defines the current fallback list.
  43676. * @param currentRank defines the current fallback rank.
  43677. * @returns the new fallback rank.
  43678. */
  43679. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43680. /**
  43681. * Add the required uniforms to the current list.
  43682. * @param uniforms defines the current uniform list.
  43683. */
  43684. static AddUniforms(uniforms: string[]): void;
  43685. /**
  43686. * Add the required samplers to the current list.
  43687. * @param samplers defines the current sampler list.
  43688. */
  43689. static AddSamplers(samplers: string[]): void;
  43690. /**
  43691. * Add the required uniforms to the current buffer.
  43692. * @param uniformBuffer defines the current uniform buffer.
  43693. */
  43694. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43695. /**
  43696. * Makes a duplicate of the current configuration into another one.
  43697. * @param configuration define the config where to copy the info
  43698. */
  43699. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  43700. /**
  43701. * Serializes this Sub Surface configuration.
  43702. * @returns - An object with the serialized config.
  43703. */
  43704. serialize(): any;
  43705. /**
  43706. * Parses a Sub Surface Configuration from a serialized object.
  43707. * @param source - Serialized object.
  43708. */
  43709. parse(source: any): void;
  43710. }
  43711. }
  43712. declare module BABYLON {
  43713. /** @hidden */
  43714. export var pbrFragmentDeclaration: {
  43715. name: string;
  43716. shader: string;
  43717. };
  43718. }
  43719. declare module BABYLON {
  43720. /** @hidden */
  43721. export var pbrUboDeclaration: {
  43722. name: string;
  43723. shader: string;
  43724. };
  43725. }
  43726. declare module BABYLON {
  43727. /** @hidden */
  43728. export var pbrFragmentExtraDeclaration: {
  43729. name: string;
  43730. shader: string;
  43731. };
  43732. }
  43733. declare module BABYLON {
  43734. /** @hidden */
  43735. export var pbrFragmentSamplersDeclaration: {
  43736. name: string;
  43737. shader: string;
  43738. };
  43739. }
  43740. declare module BABYLON {
  43741. /** @hidden */
  43742. export var pbrHelperFunctions: {
  43743. name: string;
  43744. shader: string;
  43745. };
  43746. }
  43747. declare module BABYLON {
  43748. /** @hidden */
  43749. export var harmonicsFunctions: {
  43750. name: string;
  43751. shader: string;
  43752. };
  43753. }
  43754. declare module BABYLON {
  43755. /** @hidden */
  43756. export var pbrDirectLightingSetupFunctions: {
  43757. name: string;
  43758. shader: string;
  43759. };
  43760. }
  43761. declare module BABYLON {
  43762. /** @hidden */
  43763. export var pbrDirectLightingFalloffFunctions: {
  43764. name: string;
  43765. shader: string;
  43766. };
  43767. }
  43768. declare module BABYLON {
  43769. /** @hidden */
  43770. export var pbrBRDFFunctions: {
  43771. name: string;
  43772. shader: string;
  43773. };
  43774. }
  43775. declare module BABYLON {
  43776. /** @hidden */
  43777. export var pbrDirectLightingFunctions: {
  43778. name: string;
  43779. shader: string;
  43780. };
  43781. }
  43782. declare module BABYLON {
  43783. /** @hidden */
  43784. export var pbrIBLFunctions: {
  43785. name: string;
  43786. shader: string;
  43787. };
  43788. }
  43789. declare module BABYLON {
  43790. /** @hidden */
  43791. export var pbrDebug: {
  43792. name: string;
  43793. shader: string;
  43794. };
  43795. }
  43796. declare module BABYLON {
  43797. /** @hidden */
  43798. export var pbrPixelShader: {
  43799. name: string;
  43800. shader: string;
  43801. };
  43802. }
  43803. declare module BABYLON {
  43804. /** @hidden */
  43805. export var pbrVertexDeclaration: {
  43806. name: string;
  43807. shader: string;
  43808. };
  43809. }
  43810. declare module BABYLON {
  43811. /** @hidden */
  43812. export var pbrVertexShader: {
  43813. name: string;
  43814. shader: string;
  43815. };
  43816. }
  43817. declare module BABYLON {
  43818. /**
  43819. * Manages the defines for the PBR Material.
  43820. * @hidden
  43821. */
  43822. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  43823. PBR: boolean;
  43824. MAINUV1: boolean;
  43825. MAINUV2: boolean;
  43826. UV1: boolean;
  43827. UV2: boolean;
  43828. ALBEDO: boolean;
  43829. ALBEDODIRECTUV: number;
  43830. VERTEXCOLOR: boolean;
  43831. AMBIENT: boolean;
  43832. AMBIENTDIRECTUV: number;
  43833. AMBIENTINGRAYSCALE: boolean;
  43834. OPACITY: boolean;
  43835. VERTEXALPHA: boolean;
  43836. OPACITYDIRECTUV: number;
  43837. OPACITYRGB: boolean;
  43838. ALPHATEST: boolean;
  43839. DEPTHPREPASS: boolean;
  43840. ALPHABLEND: boolean;
  43841. ALPHAFROMALBEDO: boolean;
  43842. ALPHATESTVALUE: string;
  43843. SPECULAROVERALPHA: boolean;
  43844. RADIANCEOVERALPHA: boolean;
  43845. ALPHAFRESNEL: boolean;
  43846. LINEARALPHAFRESNEL: boolean;
  43847. PREMULTIPLYALPHA: boolean;
  43848. EMISSIVE: boolean;
  43849. EMISSIVEDIRECTUV: number;
  43850. REFLECTIVITY: boolean;
  43851. REFLECTIVITYDIRECTUV: number;
  43852. SPECULARTERM: boolean;
  43853. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  43854. MICROSURFACEAUTOMATIC: boolean;
  43855. LODBASEDMICROSFURACE: boolean;
  43856. MICROSURFACEMAP: boolean;
  43857. MICROSURFACEMAPDIRECTUV: number;
  43858. METALLICWORKFLOW: boolean;
  43859. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  43860. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  43861. METALLNESSSTOREINMETALMAPBLUE: boolean;
  43862. AOSTOREINMETALMAPRED: boolean;
  43863. ENVIRONMENTBRDF: boolean;
  43864. ENVIRONMENTBRDF_RGBD: boolean;
  43865. NORMAL: boolean;
  43866. TANGENT: boolean;
  43867. BUMP: boolean;
  43868. BUMPDIRECTUV: number;
  43869. OBJECTSPACE_NORMALMAP: boolean;
  43870. PARALLAX: boolean;
  43871. PARALLAXOCCLUSION: boolean;
  43872. NORMALXYSCALE: boolean;
  43873. LIGHTMAP: boolean;
  43874. LIGHTMAPDIRECTUV: number;
  43875. USELIGHTMAPASSHADOWMAP: boolean;
  43876. GAMMALIGHTMAP: boolean;
  43877. REFLECTION: boolean;
  43878. REFLECTIONMAP_3D: boolean;
  43879. REFLECTIONMAP_SPHERICAL: boolean;
  43880. REFLECTIONMAP_PLANAR: boolean;
  43881. REFLECTIONMAP_CUBIC: boolean;
  43882. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  43883. REFLECTIONMAP_PROJECTION: boolean;
  43884. REFLECTIONMAP_SKYBOX: boolean;
  43885. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  43886. REFLECTIONMAP_EXPLICIT: boolean;
  43887. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  43888. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  43889. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  43890. INVERTCUBICMAP: boolean;
  43891. USESPHERICALFROMREFLECTIONMAP: boolean;
  43892. USESPHERICALINVERTEX: boolean;
  43893. REFLECTIONMAP_OPPOSITEZ: boolean;
  43894. LODINREFLECTIONALPHA: boolean;
  43895. GAMMAREFLECTION: boolean;
  43896. RGBDREFLECTION: boolean;
  43897. RADIANCEOCCLUSION: boolean;
  43898. HORIZONOCCLUSION: boolean;
  43899. INSTANCES: boolean;
  43900. NUM_BONE_INFLUENCERS: number;
  43901. BonesPerMesh: number;
  43902. BONETEXTURE: boolean;
  43903. NONUNIFORMSCALING: boolean;
  43904. MORPHTARGETS: boolean;
  43905. MORPHTARGETS_NORMAL: boolean;
  43906. MORPHTARGETS_TANGENT: boolean;
  43907. NUM_MORPH_INFLUENCERS: number;
  43908. IMAGEPROCESSING: boolean;
  43909. VIGNETTE: boolean;
  43910. VIGNETTEBLENDMODEMULTIPLY: boolean;
  43911. VIGNETTEBLENDMODEOPAQUE: boolean;
  43912. TONEMAPPING: boolean;
  43913. TONEMAPPING_ACES: boolean;
  43914. CONTRAST: boolean;
  43915. COLORCURVES: boolean;
  43916. COLORGRADING: boolean;
  43917. COLORGRADING3D: boolean;
  43918. SAMPLER3DGREENDEPTH: boolean;
  43919. SAMPLER3DBGRMAP: boolean;
  43920. IMAGEPROCESSINGPOSTPROCESS: boolean;
  43921. EXPOSURE: boolean;
  43922. MULTIVIEW: boolean;
  43923. USEPHYSICALLIGHTFALLOFF: boolean;
  43924. USEGLTFLIGHTFALLOFF: boolean;
  43925. TWOSIDEDLIGHTING: boolean;
  43926. SHADOWFLOAT: boolean;
  43927. CLIPPLANE: boolean;
  43928. CLIPPLANE2: boolean;
  43929. CLIPPLANE3: boolean;
  43930. CLIPPLANE4: boolean;
  43931. POINTSIZE: boolean;
  43932. FOG: boolean;
  43933. LOGARITHMICDEPTH: boolean;
  43934. FORCENORMALFORWARD: boolean;
  43935. SPECULARAA: boolean;
  43936. CLEARCOAT: boolean;
  43937. CLEARCOAT_DEFAULTIOR: boolean;
  43938. CLEARCOAT_TEXTURE: boolean;
  43939. CLEARCOAT_TEXTUREDIRECTUV: number;
  43940. CLEARCOAT_BUMP: boolean;
  43941. CLEARCOAT_BUMPDIRECTUV: number;
  43942. CLEARCOAT_TINT: boolean;
  43943. CLEARCOAT_TINT_TEXTURE: boolean;
  43944. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43945. ANISOTROPIC: boolean;
  43946. ANISOTROPIC_TEXTURE: boolean;
  43947. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43948. BRDF_V_HEIGHT_CORRELATED: boolean;
  43949. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43950. SHEEN: boolean;
  43951. SHEEN_TEXTURE: boolean;
  43952. SHEEN_TEXTUREDIRECTUV: number;
  43953. SHEEN_LINKWITHALBEDO: boolean;
  43954. SUBSURFACE: boolean;
  43955. SS_REFRACTION: boolean;
  43956. SS_TRANSLUCENCY: boolean;
  43957. SS_SCATERRING: boolean;
  43958. SS_THICKNESSANDMASK_TEXTURE: boolean;
  43959. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  43960. SS_REFRACTIONMAP_3D: boolean;
  43961. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  43962. SS_LODINREFRACTIONALPHA: boolean;
  43963. SS_GAMMAREFRACTION: boolean;
  43964. SS_RGBDREFRACTION: boolean;
  43965. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  43966. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  43967. UNLIT: boolean;
  43968. DEBUGMODE: number;
  43969. /**
  43970. * Initializes the PBR Material defines.
  43971. */
  43972. constructor();
  43973. /**
  43974. * Resets the PBR Material defines.
  43975. */
  43976. reset(): void;
  43977. }
  43978. /**
  43979. * The Physically based material base class of BJS.
  43980. *
  43981. * This offers the main features of a standard PBR material.
  43982. * For more information, please refer to the documentation :
  43983. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  43984. */
  43985. export abstract class PBRBaseMaterial extends PushMaterial {
  43986. /**
  43987. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  43988. */
  43989. static readonly PBRMATERIAL_OPAQUE: number;
  43990. /**
  43991. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  43992. */
  43993. static readonly PBRMATERIAL_ALPHATEST: number;
  43994. /**
  43995. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43996. */
  43997. static readonly PBRMATERIAL_ALPHABLEND: number;
  43998. /**
  43999. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44000. * They are also discarded below the alpha cutoff threshold to improve performances.
  44001. */
  44002. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44003. /**
  44004. * Defines the default value of how much AO map is occluding the analytical lights
  44005. * (point spot...).
  44006. */
  44007. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44008. /**
  44009. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44010. */
  44011. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44012. /**
  44013. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44014. * to enhance interoperability with other engines.
  44015. */
  44016. static readonly LIGHTFALLOFF_GLTF: number;
  44017. /**
  44018. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44019. * to enhance interoperability with other materials.
  44020. */
  44021. static readonly LIGHTFALLOFF_STANDARD: number;
  44022. /**
  44023. * Intensity of the direct lights e.g. the four lights available in your scene.
  44024. * This impacts both the direct diffuse and specular highlights.
  44025. */
  44026. protected _directIntensity: number;
  44027. /**
  44028. * Intensity of the emissive part of the material.
  44029. * This helps controlling the emissive effect without modifying the emissive color.
  44030. */
  44031. protected _emissiveIntensity: number;
  44032. /**
  44033. * Intensity of the environment e.g. how much the environment will light the object
  44034. * either through harmonics for rough material or through the refelction for shiny ones.
  44035. */
  44036. protected _environmentIntensity: number;
  44037. /**
  44038. * This is a special control allowing the reduction of the specular highlights coming from the
  44039. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44040. */
  44041. protected _specularIntensity: number;
  44042. /**
  44043. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44044. */
  44045. private _lightingInfos;
  44046. /**
  44047. * Debug Control allowing disabling the bump map on this material.
  44048. */
  44049. protected _disableBumpMap: boolean;
  44050. /**
  44051. * AKA Diffuse Texture in standard nomenclature.
  44052. */
  44053. protected _albedoTexture: BaseTexture;
  44054. /**
  44055. * AKA Occlusion Texture in other nomenclature.
  44056. */
  44057. protected _ambientTexture: BaseTexture;
  44058. /**
  44059. * AKA Occlusion Texture Intensity in other nomenclature.
  44060. */
  44061. protected _ambientTextureStrength: number;
  44062. /**
  44063. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44064. * 1 means it completely occludes it
  44065. * 0 mean it has no impact
  44066. */
  44067. protected _ambientTextureImpactOnAnalyticalLights: number;
  44068. /**
  44069. * Stores the alpha values in a texture.
  44070. */
  44071. protected _opacityTexture: BaseTexture;
  44072. /**
  44073. * Stores the reflection values in a texture.
  44074. */
  44075. protected _reflectionTexture: BaseTexture;
  44076. /**
  44077. * Stores the emissive values in a texture.
  44078. */
  44079. protected _emissiveTexture: BaseTexture;
  44080. /**
  44081. * AKA Specular texture in other nomenclature.
  44082. */
  44083. protected _reflectivityTexture: BaseTexture;
  44084. /**
  44085. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44086. */
  44087. protected _metallicTexture: BaseTexture;
  44088. /**
  44089. * Specifies the metallic scalar of the metallic/roughness workflow.
  44090. * Can also be used to scale the metalness values of the metallic texture.
  44091. */
  44092. protected _metallic: Nullable<number>;
  44093. /**
  44094. * Specifies the roughness scalar of the metallic/roughness workflow.
  44095. * Can also be used to scale the roughness values of the metallic texture.
  44096. */
  44097. protected _roughness: Nullable<number>;
  44098. /**
  44099. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44100. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44101. */
  44102. protected _microSurfaceTexture: BaseTexture;
  44103. /**
  44104. * Stores surface normal data used to displace a mesh in a texture.
  44105. */
  44106. protected _bumpTexture: BaseTexture;
  44107. /**
  44108. * Stores the pre-calculated light information of a mesh in a texture.
  44109. */
  44110. protected _lightmapTexture: BaseTexture;
  44111. /**
  44112. * The color of a material in ambient lighting.
  44113. */
  44114. protected _ambientColor: Color3;
  44115. /**
  44116. * AKA Diffuse Color in other nomenclature.
  44117. */
  44118. protected _albedoColor: Color3;
  44119. /**
  44120. * AKA Specular Color in other nomenclature.
  44121. */
  44122. protected _reflectivityColor: Color3;
  44123. /**
  44124. * The color applied when light is reflected from a material.
  44125. */
  44126. protected _reflectionColor: Color3;
  44127. /**
  44128. * The color applied when light is emitted from a material.
  44129. */
  44130. protected _emissiveColor: Color3;
  44131. /**
  44132. * AKA Glossiness in other nomenclature.
  44133. */
  44134. protected _microSurface: number;
  44135. /**
  44136. * Specifies that the material will use the light map as a show map.
  44137. */
  44138. protected _useLightmapAsShadowmap: boolean;
  44139. /**
  44140. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44141. * makes the reflect vector face the model (under horizon).
  44142. */
  44143. protected _useHorizonOcclusion: boolean;
  44144. /**
  44145. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44146. * too much the area relying on ambient texture to define their ambient occlusion.
  44147. */
  44148. protected _useRadianceOcclusion: boolean;
  44149. /**
  44150. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44151. */
  44152. protected _useAlphaFromAlbedoTexture: boolean;
  44153. /**
  44154. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44155. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44156. */
  44157. protected _useSpecularOverAlpha: boolean;
  44158. /**
  44159. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44160. */
  44161. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44162. /**
  44163. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44164. */
  44165. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44166. /**
  44167. * Specifies if the metallic texture contains the roughness information in its green channel.
  44168. */
  44169. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44170. /**
  44171. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44172. */
  44173. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44174. /**
  44175. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44176. */
  44177. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44178. /**
  44179. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44180. */
  44181. protected _useAmbientInGrayScale: boolean;
  44182. /**
  44183. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44184. * The material will try to infer what glossiness each pixel should be.
  44185. */
  44186. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44187. /**
  44188. * Defines the falloff type used in this material.
  44189. * It by default is Physical.
  44190. */
  44191. protected _lightFalloff: number;
  44192. /**
  44193. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44194. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44195. */
  44196. protected _useRadianceOverAlpha: boolean;
  44197. /**
  44198. * Allows using an object space normal map (instead of tangent space).
  44199. */
  44200. protected _useObjectSpaceNormalMap: boolean;
  44201. /**
  44202. * Allows using the bump map in parallax mode.
  44203. */
  44204. protected _useParallax: boolean;
  44205. /**
  44206. * Allows using the bump map in parallax occlusion mode.
  44207. */
  44208. protected _useParallaxOcclusion: boolean;
  44209. /**
  44210. * Controls the scale bias of the parallax mode.
  44211. */
  44212. protected _parallaxScaleBias: number;
  44213. /**
  44214. * If sets to true, disables all the lights affecting the material.
  44215. */
  44216. protected _disableLighting: boolean;
  44217. /**
  44218. * Number of Simultaneous lights allowed on the material.
  44219. */
  44220. protected _maxSimultaneousLights: number;
  44221. /**
  44222. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44223. */
  44224. protected _invertNormalMapX: boolean;
  44225. /**
  44226. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44227. */
  44228. protected _invertNormalMapY: boolean;
  44229. /**
  44230. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44231. */
  44232. protected _twoSidedLighting: boolean;
  44233. /**
  44234. * Defines the alpha limits in alpha test mode.
  44235. */
  44236. protected _alphaCutOff: number;
  44237. /**
  44238. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44239. */
  44240. protected _forceAlphaTest: boolean;
  44241. /**
  44242. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44243. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44244. */
  44245. protected _useAlphaFresnel: boolean;
  44246. /**
  44247. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44248. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44249. */
  44250. protected _useLinearAlphaFresnel: boolean;
  44251. /**
  44252. * The transparency mode of the material.
  44253. */
  44254. protected _transparencyMode: Nullable<number>;
  44255. /**
  44256. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44257. * from cos thetav and roughness:
  44258. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44259. */
  44260. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44261. /**
  44262. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44263. */
  44264. protected _forceIrradianceInFragment: boolean;
  44265. /**
  44266. * Force normal to face away from face.
  44267. */
  44268. protected _forceNormalForward: boolean;
  44269. /**
  44270. * Enables specular anti aliasing in the PBR shader.
  44271. * It will both interacts on the Geometry for analytical and IBL lighting.
  44272. * It also prefilter the roughness map based on the bump values.
  44273. */
  44274. protected _enableSpecularAntiAliasing: boolean;
  44275. /**
  44276. * Default configuration related to image processing available in the PBR Material.
  44277. */
  44278. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44279. /**
  44280. * Keep track of the image processing observer to allow dispose and replace.
  44281. */
  44282. private _imageProcessingObserver;
  44283. /**
  44284. * Attaches a new image processing configuration to the PBR Material.
  44285. * @param configuration
  44286. */
  44287. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44288. /**
  44289. * Stores the available render targets.
  44290. */
  44291. private _renderTargets;
  44292. /**
  44293. * Sets the global ambient color for the material used in lighting calculations.
  44294. */
  44295. private _globalAmbientColor;
  44296. /**
  44297. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44298. */
  44299. private _useLogarithmicDepth;
  44300. /**
  44301. * If set to true, no lighting calculations will be applied.
  44302. */
  44303. private _unlit;
  44304. private _debugMode;
  44305. /**
  44306. * @hidden
  44307. * This is reserved for the inspector.
  44308. * Defines the material debug mode.
  44309. * It helps seeing only some components of the material while troubleshooting.
  44310. */
  44311. debugMode: number;
  44312. /**
  44313. * @hidden
  44314. * This is reserved for the inspector.
  44315. * Specify from where on screen the debug mode should start.
  44316. * The value goes from -1 (full screen) to 1 (not visible)
  44317. * It helps with side by side comparison against the final render
  44318. * This defaults to -1
  44319. */
  44320. private debugLimit;
  44321. /**
  44322. * @hidden
  44323. * This is reserved for the inspector.
  44324. * As the default viewing range might not be enough (if the ambient is really small for instance)
  44325. * You can use the factor to better multiply the final value.
  44326. */
  44327. private debugFactor;
  44328. /**
  44329. * Defines the clear coat layer parameters for the material.
  44330. */
  44331. readonly clearCoat: PBRClearCoatConfiguration;
  44332. /**
  44333. * Defines the anisotropic parameters for the material.
  44334. */
  44335. readonly anisotropy: PBRAnisotropicConfiguration;
  44336. /**
  44337. * Defines the BRDF parameters for the material.
  44338. */
  44339. readonly brdf: PBRBRDFConfiguration;
  44340. /**
  44341. * Defines the Sheen parameters for the material.
  44342. */
  44343. readonly sheen: PBRSheenConfiguration;
  44344. /**
  44345. * Defines the SubSurface parameters for the material.
  44346. */
  44347. readonly subSurface: PBRSubSurfaceConfiguration;
  44348. /**
  44349. * Custom callback helping to override the default shader used in the material.
  44350. */
  44351. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  44352. /**
  44353. * Instantiates a new PBRMaterial instance.
  44354. *
  44355. * @param name The material name
  44356. * @param scene The scene the material will be use in.
  44357. */
  44358. constructor(name: string, scene: Scene);
  44359. /**
  44360. * Gets a boolean indicating that current material needs to register RTT
  44361. */
  44362. readonly hasRenderTargetTextures: boolean;
  44363. /**
  44364. * Gets the name of the material class.
  44365. */
  44366. getClassName(): string;
  44367. /**
  44368. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44369. */
  44370. /**
  44371. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44372. */
  44373. useLogarithmicDepth: boolean;
  44374. /**
  44375. * Gets the current transparency mode.
  44376. */
  44377. /**
  44378. * Sets the transparency mode of the material.
  44379. *
  44380. * | Value | Type | Description |
  44381. * | ----- | ----------------------------------- | ----------- |
  44382. * | 0 | OPAQUE | |
  44383. * | 1 | ALPHATEST | |
  44384. * | 2 | ALPHABLEND | |
  44385. * | 3 | ALPHATESTANDBLEND | |
  44386. *
  44387. */
  44388. transparencyMode: Nullable<number>;
  44389. /**
  44390. * Returns true if alpha blending should be disabled.
  44391. */
  44392. private readonly _disableAlphaBlending;
  44393. /**
  44394. * Specifies whether or not this material should be rendered in alpha blend mode.
  44395. */
  44396. needAlphaBlending(): boolean;
  44397. /**
  44398. * Specifies if the mesh will require alpha blending.
  44399. * @param mesh - BJS mesh.
  44400. */
  44401. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44402. /**
  44403. * Specifies whether or not this material should be rendered in alpha test mode.
  44404. */
  44405. needAlphaTesting(): boolean;
  44406. /**
  44407. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44408. */
  44409. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44410. /**
  44411. * Gets the texture used for the alpha test.
  44412. */
  44413. getAlphaTestTexture(): BaseTexture;
  44414. /**
  44415. * Specifies that the submesh is ready to be used.
  44416. * @param mesh - BJS mesh.
  44417. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44418. * @param useInstances - Specifies that instances should be used.
  44419. * @returns - boolean indicating that the submesh is ready or not.
  44420. */
  44421. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44422. /**
  44423. * Specifies if the material uses metallic roughness workflow.
  44424. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44425. */
  44426. isMetallicWorkflow(): boolean;
  44427. private _prepareEffect;
  44428. private _prepareDefines;
  44429. /**
  44430. * Force shader compilation
  44431. */
  44432. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44433. clipPlane: boolean;
  44434. }>): void;
  44435. /**
  44436. * Initializes the uniform buffer layout for the shader.
  44437. */
  44438. buildUniformLayout(): void;
  44439. /**
  44440. * Unbinds the material from the mesh
  44441. */
  44442. unbind(): void;
  44443. /**
  44444. * Binds the submesh data.
  44445. * @param world - The world matrix.
  44446. * @param mesh - The BJS mesh.
  44447. * @param subMesh - A submesh of the BJS mesh.
  44448. */
  44449. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44450. /**
  44451. * Returns the animatable textures.
  44452. * @returns - Array of animatable textures.
  44453. */
  44454. getAnimatables(): IAnimatable[];
  44455. /**
  44456. * Returns the texture used for reflections.
  44457. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44458. */
  44459. private _getReflectionTexture;
  44460. /**
  44461. * Returns an array of the actively used textures.
  44462. * @returns - Array of BaseTextures
  44463. */
  44464. getActiveTextures(): BaseTexture[];
  44465. /**
  44466. * Checks to see if a texture is used in the material.
  44467. * @param texture - Base texture to use.
  44468. * @returns - Boolean specifying if a texture is used in the material.
  44469. */
  44470. hasTexture(texture: BaseTexture): boolean;
  44471. /**
  44472. * Disposes the resources of the material.
  44473. * @param forceDisposeEffect - Forces the disposal of effects.
  44474. * @param forceDisposeTextures - Forces the disposal of all textures.
  44475. */
  44476. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44477. }
  44478. }
  44479. declare module BABYLON {
  44480. /**
  44481. * The Physically based material of BJS.
  44482. *
  44483. * This offers the main features of a standard PBR material.
  44484. * For more information, please refer to the documentation :
  44485. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44486. */
  44487. export class PBRMaterial extends PBRBaseMaterial {
  44488. /**
  44489. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44490. */
  44491. static readonly PBRMATERIAL_OPAQUE: number;
  44492. /**
  44493. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44494. */
  44495. static readonly PBRMATERIAL_ALPHATEST: number;
  44496. /**
  44497. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44498. */
  44499. static readonly PBRMATERIAL_ALPHABLEND: number;
  44500. /**
  44501. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44502. * They are also discarded below the alpha cutoff threshold to improve performances.
  44503. */
  44504. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44505. /**
  44506. * Defines the default value of how much AO map is occluding the analytical lights
  44507. * (point spot...).
  44508. */
  44509. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44510. /**
  44511. * Intensity of the direct lights e.g. the four lights available in your scene.
  44512. * This impacts both the direct diffuse and specular highlights.
  44513. */
  44514. directIntensity: number;
  44515. /**
  44516. * Intensity of the emissive part of the material.
  44517. * This helps controlling the emissive effect without modifying the emissive color.
  44518. */
  44519. emissiveIntensity: number;
  44520. /**
  44521. * Intensity of the environment e.g. how much the environment will light the object
  44522. * either through harmonics for rough material or through the refelction for shiny ones.
  44523. */
  44524. environmentIntensity: number;
  44525. /**
  44526. * This is a special control allowing the reduction of the specular highlights coming from the
  44527. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44528. */
  44529. specularIntensity: number;
  44530. /**
  44531. * Debug Control allowing disabling the bump map on this material.
  44532. */
  44533. disableBumpMap: boolean;
  44534. /**
  44535. * AKA Diffuse Texture in standard nomenclature.
  44536. */
  44537. albedoTexture: BaseTexture;
  44538. /**
  44539. * AKA Occlusion Texture in other nomenclature.
  44540. */
  44541. ambientTexture: BaseTexture;
  44542. /**
  44543. * AKA Occlusion Texture Intensity in other nomenclature.
  44544. */
  44545. ambientTextureStrength: number;
  44546. /**
  44547. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44548. * 1 means it completely occludes it
  44549. * 0 mean it has no impact
  44550. */
  44551. ambientTextureImpactOnAnalyticalLights: number;
  44552. /**
  44553. * Stores the alpha values in a texture.
  44554. */
  44555. opacityTexture: BaseTexture;
  44556. /**
  44557. * Stores the reflection values in a texture.
  44558. */
  44559. reflectionTexture: Nullable<BaseTexture>;
  44560. /**
  44561. * Stores the emissive values in a texture.
  44562. */
  44563. emissiveTexture: BaseTexture;
  44564. /**
  44565. * AKA Specular texture in other nomenclature.
  44566. */
  44567. reflectivityTexture: BaseTexture;
  44568. /**
  44569. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44570. */
  44571. metallicTexture: BaseTexture;
  44572. /**
  44573. * Specifies the metallic scalar of the metallic/roughness workflow.
  44574. * Can also be used to scale the metalness values of the metallic texture.
  44575. */
  44576. metallic: Nullable<number>;
  44577. /**
  44578. * Specifies the roughness scalar of the metallic/roughness workflow.
  44579. * Can also be used to scale the roughness values of the metallic texture.
  44580. */
  44581. roughness: Nullable<number>;
  44582. /**
  44583. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44584. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44585. */
  44586. microSurfaceTexture: BaseTexture;
  44587. /**
  44588. * Stores surface normal data used to displace a mesh in a texture.
  44589. */
  44590. bumpTexture: BaseTexture;
  44591. /**
  44592. * Stores the pre-calculated light information of a mesh in a texture.
  44593. */
  44594. lightmapTexture: BaseTexture;
  44595. /**
  44596. * Stores the refracted light information in a texture.
  44597. */
  44598. refractionTexture: Nullable<BaseTexture>;
  44599. /**
  44600. * The color of a material in ambient lighting.
  44601. */
  44602. ambientColor: Color3;
  44603. /**
  44604. * AKA Diffuse Color in other nomenclature.
  44605. */
  44606. albedoColor: Color3;
  44607. /**
  44608. * AKA Specular Color in other nomenclature.
  44609. */
  44610. reflectivityColor: Color3;
  44611. /**
  44612. * The color reflected from the material.
  44613. */
  44614. reflectionColor: Color3;
  44615. /**
  44616. * The color emitted from the material.
  44617. */
  44618. emissiveColor: Color3;
  44619. /**
  44620. * AKA Glossiness in other nomenclature.
  44621. */
  44622. microSurface: number;
  44623. /**
  44624. * source material index of refraction (IOR)' / 'destination material IOR.
  44625. */
  44626. indexOfRefraction: number;
  44627. /**
  44628. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44629. */
  44630. invertRefractionY: boolean;
  44631. /**
  44632. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44633. * Materials half opaque for instance using refraction could benefit from this control.
  44634. */
  44635. linkRefractionWithTransparency: boolean;
  44636. /**
  44637. * If true, the light map contains occlusion information instead of lighting info.
  44638. */
  44639. useLightmapAsShadowmap: boolean;
  44640. /**
  44641. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44642. */
  44643. useAlphaFromAlbedoTexture: boolean;
  44644. /**
  44645. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44646. */
  44647. forceAlphaTest: boolean;
  44648. /**
  44649. * Defines the alpha limits in alpha test mode.
  44650. */
  44651. alphaCutOff: number;
  44652. /**
  44653. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44654. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44655. */
  44656. useSpecularOverAlpha: boolean;
  44657. /**
  44658. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44659. */
  44660. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44661. /**
  44662. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44663. */
  44664. useRoughnessFromMetallicTextureAlpha: boolean;
  44665. /**
  44666. * Specifies if the metallic texture contains the roughness information in its green channel.
  44667. */
  44668. useRoughnessFromMetallicTextureGreen: boolean;
  44669. /**
  44670. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44671. */
  44672. useMetallnessFromMetallicTextureBlue: boolean;
  44673. /**
  44674. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44675. */
  44676. useAmbientOcclusionFromMetallicTextureRed: boolean;
  44677. /**
  44678. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44679. */
  44680. useAmbientInGrayScale: boolean;
  44681. /**
  44682. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44683. * The material will try to infer what glossiness each pixel should be.
  44684. */
  44685. useAutoMicroSurfaceFromReflectivityMap: boolean;
  44686. /**
  44687. * BJS is using an harcoded light falloff based on a manually sets up range.
  44688. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44689. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44690. */
  44691. /**
  44692. * BJS is using an harcoded light falloff based on a manually sets up range.
  44693. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44694. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44695. */
  44696. usePhysicalLightFalloff: boolean;
  44697. /**
  44698. * In order to support the falloff compatibility with gltf, a special mode has been added
  44699. * to reproduce the gltf light falloff.
  44700. */
  44701. /**
  44702. * In order to support the falloff compatibility with gltf, a special mode has been added
  44703. * to reproduce the gltf light falloff.
  44704. */
  44705. useGLTFLightFalloff: boolean;
  44706. /**
  44707. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44708. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44709. */
  44710. useRadianceOverAlpha: boolean;
  44711. /**
  44712. * Allows using an object space normal map (instead of tangent space).
  44713. */
  44714. useObjectSpaceNormalMap: boolean;
  44715. /**
  44716. * Allows using the bump map in parallax mode.
  44717. */
  44718. useParallax: boolean;
  44719. /**
  44720. * Allows using the bump map in parallax occlusion mode.
  44721. */
  44722. useParallaxOcclusion: boolean;
  44723. /**
  44724. * Controls the scale bias of the parallax mode.
  44725. */
  44726. parallaxScaleBias: number;
  44727. /**
  44728. * If sets to true, disables all the lights affecting the material.
  44729. */
  44730. disableLighting: boolean;
  44731. /**
  44732. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44733. */
  44734. forceIrradianceInFragment: boolean;
  44735. /**
  44736. * Number of Simultaneous lights allowed on the material.
  44737. */
  44738. maxSimultaneousLights: number;
  44739. /**
  44740. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44741. */
  44742. invertNormalMapX: boolean;
  44743. /**
  44744. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44745. */
  44746. invertNormalMapY: boolean;
  44747. /**
  44748. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44749. */
  44750. twoSidedLighting: boolean;
  44751. /**
  44752. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44753. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44754. */
  44755. useAlphaFresnel: boolean;
  44756. /**
  44757. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44758. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44759. */
  44760. useLinearAlphaFresnel: boolean;
  44761. /**
  44762. * Let user defines the brdf lookup texture used for IBL.
  44763. * A default 8bit version is embedded but you could point at :
  44764. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  44765. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  44766. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44767. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  44768. */
  44769. environmentBRDFTexture: Nullable<BaseTexture>;
  44770. /**
  44771. * Force normal to face away from face.
  44772. */
  44773. forceNormalForward: boolean;
  44774. /**
  44775. * Enables specular anti aliasing in the PBR shader.
  44776. * It will both interacts on the Geometry for analytical and IBL lighting.
  44777. * It also prefilter the roughness map based on the bump values.
  44778. */
  44779. enableSpecularAntiAliasing: boolean;
  44780. /**
  44781. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44782. * makes the reflect vector face the model (under horizon).
  44783. */
  44784. useHorizonOcclusion: boolean;
  44785. /**
  44786. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44787. * too much the area relying on ambient texture to define their ambient occlusion.
  44788. */
  44789. useRadianceOcclusion: boolean;
  44790. /**
  44791. * If set to true, no lighting calculations will be applied.
  44792. */
  44793. unlit: boolean;
  44794. /**
  44795. * Gets the image processing configuration used either in this material.
  44796. */
  44797. /**
  44798. * Sets the Default image processing configuration used either in the this material.
  44799. *
  44800. * If sets to null, the scene one is in use.
  44801. */
  44802. imageProcessingConfiguration: ImageProcessingConfiguration;
  44803. /**
  44804. * Gets wether the color curves effect is enabled.
  44805. */
  44806. /**
  44807. * Sets wether the color curves effect is enabled.
  44808. */
  44809. cameraColorCurvesEnabled: boolean;
  44810. /**
  44811. * Gets wether the color grading effect is enabled.
  44812. */
  44813. /**
  44814. * Gets wether the color grading effect is enabled.
  44815. */
  44816. cameraColorGradingEnabled: boolean;
  44817. /**
  44818. * Gets wether tonemapping is enabled or not.
  44819. */
  44820. /**
  44821. * Sets wether tonemapping is enabled or not
  44822. */
  44823. cameraToneMappingEnabled: boolean;
  44824. /**
  44825. * The camera exposure used on this material.
  44826. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44827. * This corresponds to a photographic exposure.
  44828. */
  44829. /**
  44830. * The camera exposure used on this material.
  44831. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44832. * This corresponds to a photographic exposure.
  44833. */
  44834. cameraExposure: number;
  44835. /**
  44836. * Gets The camera contrast used on this material.
  44837. */
  44838. /**
  44839. * Sets The camera contrast used on this material.
  44840. */
  44841. cameraContrast: number;
  44842. /**
  44843. * Gets the Color Grading 2D Lookup Texture.
  44844. */
  44845. /**
  44846. * Sets the Color Grading 2D Lookup Texture.
  44847. */
  44848. cameraColorGradingTexture: Nullable<BaseTexture>;
  44849. /**
  44850. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44851. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44852. * 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;
  44853. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44854. */
  44855. /**
  44856. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44857. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44858. * 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;
  44859. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44860. */
  44861. cameraColorCurves: Nullable<ColorCurves>;
  44862. /**
  44863. * Instantiates a new PBRMaterial instance.
  44864. *
  44865. * @param name The material name
  44866. * @param scene The scene the material will be use in.
  44867. */
  44868. constructor(name: string, scene: Scene);
  44869. /**
  44870. * Returns the name of this material class.
  44871. */
  44872. getClassName(): string;
  44873. /**
  44874. * Makes a duplicate of the current material.
  44875. * @param name - name to use for the new material.
  44876. */
  44877. clone(name: string): PBRMaterial;
  44878. /**
  44879. * Serializes this PBR Material.
  44880. * @returns - An object with the serialized material.
  44881. */
  44882. serialize(): any;
  44883. /**
  44884. * Parses a PBR Material from a serialized object.
  44885. * @param source - Serialized object.
  44886. * @param scene - BJS scene instance.
  44887. * @param rootUrl - url for the scene object
  44888. * @returns - PBRMaterial
  44889. */
  44890. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  44891. }
  44892. }
  44893. declare module BABYLON {
  44894. /**
  44895. * Direct draw surface info
  44896. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  44897. */
  44898. export interface DDSInfo {
  44899. /**
  44900. * Width of the texture
  44901. */
  44902. width: number;
  44903. /**
  44904. * Width of the texture
  44905. */
  44906. height: number;
  44907. /**
  44908. * Number of Mipmaps for the texture
  44909. * @see https://en.wikipedia.org/wiki/Mipmap
  44910. */
  44911. mipmapCount: number;
  44912. /**
  44913. * If the textures format is a known fourCC format
  44914. * @see https://www.fourcc.org/
  44915. */
  44916. isFourCC: boolean;
  44917. /**
  44918. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  44919. */
  44920. isRGB: boolean;
  44921. /**
  44922. * If the texture is a lumincance format
  44923. */
  44924. isLuminance: boolean;
  44925. /**
  44926. * If this is a cube texture
  44927. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  44928. */
  44929. isCube: boolean;
  44930. /**
  44931. * If the texture is a compressed format eg. FOURCC_DXT1
  44932. */
  44933. isCompressed: boolean;
  44934. /**
  44935. * The dxgiFormat of the texture
  44936. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  44937. */
  44938. dxgiFormat: number;
  44939. /**
  44940. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  44941. */
  44942. textureType: number;
  44943. /**
  44944. * Sphericle polynomial created for the dds texture
  44945. */
  44946. sphericalPolynomial?: SphericalPolynomial;
  44947. }
  44948. /**
  44949. * Class used to provide DDS decompression tools
  44950. */
  44951. export class DDSTools {
  44952. /**
  44953. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  44954. */
  44955. static StoreLODInAlphaChannel: boolean;
  44956. /**
  44957. * Gets DDS information from an array buffer
  44958. * @param arrayBuffer defines the array buffer to read data from
  44959. * @returns the DDS information
  44960. */
  44961. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  44962. private static _FloatView;
  44963. private static _Int32View;
  44964. private static _ToHalfFloat;
  44965. private static _FromHalfFloat;
  44966. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  44967. private static _GetHalfFloatRGBAArrayBuffer;
  44968. private static _GetFloatRGBAArrayBuffer;
  44969. private static _GetFloatAsUIntRGBAArrayBuffer;
  44970. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  44971. private static _GetRGBAArrayBuffer;
  44972. private static _ExtractLongWordOrder;
  44973. private static _GetRGBArrayBuffer;
  44974. private static _GetLuminanceArrayBuffer;
  44975. /**
  44976. * Uploads DDS Levels to a Babylon Texture
  44977. * @hidden
  44978. */
  44979. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  44980. }
  44981. interface Engine {
  44982. /**
  44983. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  44984. * @param rootUrl defines the url where the file to load is located
  44985. * @param scene defines the current scene
  44986. * @param lodScale defines scale to apply to the mip map selection
  44987. * @param lodOffset defines offset to apply to the mip map selection
  44988. * @param onLoad defines an optional callback raised when the texture is loaded
  44989. * @param onError defines an optional callback raised if there is an issue to load the texture
  44990. * @param format defines the format of the data
  44991. * @param forcedExtension defines the extension to use to pick the right loader
  44992. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  44993. * @returns the cube texture as an InternalTexture
  44994. */
  44995. 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;
  44996. }
  44997. }
  44998. declare module BABYLON {
  44999. /**
  45000. * Implementation of the DDS Texture Loader.
  45001. * @hidden
  45002. */
  45003. export class _DDSTextureLoader implements IInternalTextureLoader {
  45004. /**
  45005. * Defines wether the loader supports cascade loading the different faces.
  45006. */
  45007. readonly supportCascades: boolean;
  45008. /**
  45009. * This returns if the loader support the current file information.
  45010. * @param extension defines the file extension of the file being loaded
  45011. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45012. * @param fallback defines the fallback internal texture if any
  45013. * @param isBase64 defines whether the texture is encoded as a base64
  45014. * @param isBuffer defines whether the texture data are stored as a buffer
  45015. * @returns true if the loader can load the specified file
  45016. */
  45017. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45018. /**
  45019. * Transform the url before loading if required.
  45020. * @param rootUrl the url of the texture
  45021. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45022. * @returns the transformed texture
  45023. */
  45024. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45025. /**
  45026. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45027. * @param rootUrl the url of the texture
  45028. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45029. * @returns the fallback texture
  45030. */
  45031. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45032. /**
  45033. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45034. * @param data contains the texture data
  45035. * @param texture defines the BabylonJS internal texture
  45036. * @param createPolynomials will be true if polynomials have been requested
  45037. * @param onLoad defines the callback to trigger once the texture is ready
  45038. * @param onError defines the callback to trigger in case of error
  45039. */
  45040. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45041. /**
  45042. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45043. * @param data contains the texture data
  45044. * @param texture defines the BabylonJS internal texture
  45045. * @param callback defines the method to call once ready to upload
  45046. */
  45047. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45048. }
  45049. }
  45050. declare module BABYLON {
  45051. /** @hidden */
  45052. export var rgbdEncodePixelShader: {
  45053. name: string;
  45054. shader: string;
  45055. };
  45056. }
  45057. declare module BABYLON {
  45058. /**
  45059. * Raw texture data and descriptor sufficient for WebGL texture upload
  45060. */
  45061. export interface EnvironmentTextureInfo {
  45062. /**
  45063. * Version of the environment map
  45064. */
  45065. version: number;
  45066. /**
  45067. * Width of image
  45068. */
  45069. width: number;
  45070. /**
  45071. * Irradiance information stored in the file.
  45072. */
  45073. irradiance: any;
  45074. /**
  45075. * Specular information stored in the file.
  45076. */
  45077. specular: any;
  45078. }
  45079. /**
  45080. * Sets of helpers addressing the serialization and deserialization of environment texture
  45081. * stored in a BabylonJS env file.
  45082. * Those files are usually stored as .env files.
  45083. */
  45084. export class EnvironmentTextureTools {
  45085. /**
  45086. * Magic number identifying the env file.
  45087. */
  45088. private static _MagicBytes;
  45089. /**
  45090. * Gets the environment info from an env file.
  45091. * @param data The array buffer containing the .env bytes.
  45092. * @returns the environment file info (the json header) if successfully parsed.
  45093. */
  45094. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45095. /**
  45096. * Creates an environment texture from a loaded cube texture.
  45097. * @param texture defines the cube texture to convert in env file
  45098. * @return a promise containing the environment data if succesfull.
  45099. */
  45100. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45101. /**
  45102. * Creates a JSON representation of the spherical data.
  45103. * @param texture defines the texture containing the polynomials
  45104. * @return the JSON representation of the spherical info
  45105. */
  45106. private static _CreateEnvTextureIrradiance;
  45107. /**
  45108. * Uploads the texture info contained in the env file to the GPU.
  45109. * @param texture defines the internal texture to upload to
  45110. * @param arrayBuffer defines the buffer cotaining the data to load
  45111. * @param info defines the texture info retrieved through the GetEnvInfo method
  45112. * @returns a promise
  45113. */
  45114. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45115. /**
  45116. * Uploads the levels of image data to the GPU.
  45117. * @param texture defines the internal texture to upload to
  45118. * @param imageData defines the array buffer views of image data [mipmap][face]
  45119. * @returns a promise
  45120. */
  45121. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45122. /**
  45123. * Uploads spherical polynomials information to the texture.
  45124. * @param texture defines the texture we are trying to upload the information to
  45125. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45126. */
  45127. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45128. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45129. }
  45130. }
  45131. declare module BABYLON {
  45132. /**
  45133. * Implementation of the ENV Texture Loader.
  45134. * @hidden
  45135. */
  45136. export class _ENVTextureLoader implements IInternalTextureLoader {
  45137. /**
  45138. * Defines wether the loader supports cascade loading the different faces.
  45139. */
  45140. readonly supportCascades: boolean;
  45141. /**
  45142. * This returns if the loader support the current file information.
  45143. * @param extension defines the file extension of the file being loaded
  45144. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45145. * @param fallback defines the fallback internal texture if any
  45146. * @param isBase64 defines whether the texture is encoded as a base64
  45147. * @param isBuffer defines whether the texture data are stored as a buffer
  45148. * @returns true if the loader can load the specified file
  45149. */
  45150. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45151. /**
  45152. * Transform the url before loading if required.
  45153. * @param rootUrl the url of the texture
  45154. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45155. * @returns the transformed texture
  45156. */
  45157. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45158. /**
  45159. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45160. * @param rootUrl the url of the texture
  45161. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45162. * @returns the fallback texture
  45163. */
  45164. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45165. /**
  45166. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45167. * @param data contains the texture data
  45168. * @param texture defines the BabylonJS internal texture
  45169. * @param createPolynomials will be true if polynomials have been requested
  45170. * @param onLoad defines the callback to trigger once the texture is ready
  45171. * @param onError defines the callback to trigger in case of error
  45172. */
  45173. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45174. /**
  45175. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45176. * @param data contains the texture data
  45177. * @param texture defines the BabylonJS internal texture
  45178. * @param callback defines the method to call once ready to upload
  45179. */
  45180. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45181. }
  45182. }
  45183. declare module BABYLON {
  45184. /**
  45185. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  45186. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  45187. */
  45188. export class KhronosTextureContainer {
  45189. /** contents of the KTX container file */
  45190. arrayBuffer: any;
  45191. private static HEADER_LEN;
  45192. private static COMPRESSED_2D;
  45193. private static COMPRESSED_3D;
  45194. private static TEX_2D;
  45195. private static TEX_3D;
  45196. /**
  45197. * Gets the openGL type
  45198. */
  45199. glType: number;
  45200. /**
  45201. * Gets the openGL type size
  45202. */
  45203. glTypeSize: number;
  45204. /**
  45205. * Gets the openGL format
  45206. */
  45207. glFormat: number;
  45208. /**
  45209. * Gets the openGL internal format
  45210. */
  45211. glInternalFormat: number;
  45212. /**
  45213. * Gets the base internal format
  45214. */
  45215. glBaseInternalFormat: number;
  45216. /**
  45217. * Gets image width in pixel
  45218. */
  45219. pixelWidth: number;
  45220. /**
  45221. * Gets image height in pixel
  45222. */
  45223. pixelHeight: number;
  45224. /**
  45225. * Gets image depth in pixels
  45226. */
  45227. pixelDepth: number;
  45228. /**
  45229. * Gets the number of array elements
  45230. */
  45231. numberOfArrayElements: number;
  45232. /**
  45233. * Gets the number of faces
  45234. */
  45235. numberOfFaces: number;
  45236. /**
  45237. * Gets the number of mipmap levels
  45238. */
  45239. numberOfMipmapLevels: number;
  45240. /**
  45241. * Gets the bytes of key value data
  45242. */
  45243. bytesOfKeyValueData: number;
  45244. /**
  45245. * Gets the load type
  45246. */
  45247. loadType: number;
  45248. /**
  45249. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  45250. */
  45251. isInvalid: boolean;
  45252. /**
  45253. * Creates a new KhronosTextureContainer
  45254. * @param arrayBuffer contents of the KTX container file
  45255. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  45256. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  45257. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  45258. */
  45259. constructor(
  45260. /** contents of the KTX container file */
  45261. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  45262. /**
  45263. * Uploads KTX content to a Babylon Texture.
  45264. * It is assumed that the texture has already been created & is currently bound
  45265. * @hidden
  45266. */
  45267. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  45268. private _upload2DCompressedLevels;
  45269. }
  45270. }
  45271. declare module BABYLON {
  45272. /**
  45273. * Implementation of the KTX Texture Loader.
  45274. * @hidden
  45275. */
  45276. export class _KTXTextureLoader implements IInternalTextureLoader {
  45277. /**
  45278. * Defines wether the loader supports cascade loading the different faces.
  45279. */
  45280. readonly supportCascades: boolean;
  45281. /**
  45282. * This returns if the loader support the current file information.
  45283. * @param extension defines the file extension of the file being loaded
  45284. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45285. * @param fallback defines the fallback internal texture if any
  45286. * @param isBase64 defines whether the texture is encoded as a base64
  45287. * @param isBuffer defines whether the texture data are stored as a buffer
  45288. * @returns true if the loader can load the specified file
  45289. */
  45290. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45291. /**
  45292. * Transform the url before loading if required.
  45293. * @param rootUrl the url of the texture
  45294. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45295. * @returns the transformed texture
  45296. */
  45297. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45298. /**
  45299. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45300. * @param rootUrl the url of the texture
  45301. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45302. * @returns the fallback texture
  45303. */
  45304. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45305. /**
  45306. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45307. * @param data contains the texture data
  45308. * @param texture defines the BabylonJS internal texture
  45309. * @param createPolynomials will be true if polynomials have been requested
  45310. * @param onLoad defines the callback to trigger once the texture is ready
  45311. * @param onError defines the callback to trigger in case of error
  45312. */
  45313. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45314. /**
  45315. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45316. * @param data contains the texture data
  45317. * @param texture defines the BabylonJS internal texture
  45318. * @param callback defines the method to call once ready to upload
  45319. */
  45320. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  45321. }
  45322. }
  45323. declare module BABYLON {
  45324. /** @hidden */
  45325. export var _forceSceneHelpersToBundle: boolean;
  45326. interface Scene {
  45327. /**
  45328. * Creates a default light for the scene.
  45329. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45330. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45331. */
  45332. createDefaultLight(replace?: boolean): void;
  45333. /**
  45334. * Creates a default camera for the scene.
  45335. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45336. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45337. * @param replace has default false, when true replaces the active camera in the scene
  45338. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45339. */
  45340. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45341. /**
  45342. * Creates a default camera and a default light.
  45343. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45344. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45345. * @param replace has the default false, when true replaces the active camera/light in the scene
  45346. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45347. */
  45348. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45349. /**
  45350. * Creates a new sky box
  45351. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45352. * @param environmentTexture defines the texture to use as environment texture
  45353. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45354. * @param scale defines the overall scale of the skybox
  45355. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45356. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45357. * @returns a new mesh holding the sky box
  45358. */
  45359. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45360. /**
  45361. * Creates a new environment
  45362. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45363. * @param options defines the options you can use to configure the environment
  45364. * @returns the new EnvironmentHelper
  45365. */
  45366. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45367. /**
  45368. * Creates a new VREXperienceHelper
  45369. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45370. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45371. * @returns a new VREXperienceHelper
  45372. */
  45373. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45374. /**
  45375. * Creates a new XREXperienceHelper
  45376. * @see http://doc.babylonjs.com/how_to/webxr
  45377. * @returns a promise for a new XREXperienceHelper
  45378. */
  45379. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45380. }
  45381. }
  45382. declare module BABYLON {
  45383. /**
  45384. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45385. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45386. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45387. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45388. */
  45389. export class VideoDome extends TransformNode {
  45390. /**
  45391. * Define the video source as a Monoscopic panoramic 360 video.
  45392. */
  45393. static readonly MODE_MONOSCOPIC: number;
  45394. /**
  45395. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45396. */
  45397. static readonly MODE_TOPBOTTOM: number;
  45398. /**
  45399. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45400. */
  45401. static readonly MODE_SIDEBYSIDE: number;
  45402. private _useDirectMapping;
  45403. /**
  45404. * The video texture being displayed on the sphere
  45405. */
  45406. protected _videoTexture: VideoTexture;
  45407. /**
  45408. * Gets the video texture being displayed on the sphere
  45409. */
  45410. readonly videoTexture: VideoTexture;
  45411. /**
  45412. * The skybox material
  45413. */
  45414. protected _material: BackgroundMaterial;
  45415. /**
  45416. * The surface used for the skybox
  45417. */
  45418. protected _mesh: Mesh;
  45419. /**
  45420. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45421. * Also see the options.resolution property.
  45422. */
  45423. fovMultiplier: number;
  45424. private _videoMode;
  45425. /**
  45426. * Gets or set the current video mode for the video. It can be:
  45427. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  45428. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45429. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45430. */
  45431. videoMode: number;
  45432. /**
  45433. * Oberserver used in Stereoscopic VR Mode.
  45434. */
  45435. private _onBeforeCameraRenderObserver;
  45436. /**
  45437. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45438. * @param name Element's name, child elements will append suffixes for their own names.
  45439. * @param urlsOrVideo defines the url(s) or the video element to use
  45440. * @param options An object containing optional or exposed sub element properties
  45441. */
  45442. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45443. resolution?: number;
  45444. clickToPlay?: boolean;
  45445. autoPlay?: boolean;
  45446. loop?: boolean;
  45447. size?: number;
  45448. poster?: string;
  45449. faceForward?: boolean;
  45450. useDirectMapping?: boolean;
  45451. }, scene: Scene);
  45452. private _changeVideoMode;
  45453. /**
  45454. * Releases resources associated with this node.
  45455. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45456. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45457. */
  45458. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45459. }
  45460. }
  45461. declare module BABYLON {
  45462. /**
  45463. * This class can be used to get instrumentation data from a Babylon engine
  45464. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45465. */
  45466. export class EngineInstrumentation implements IDisposable {
  45467. /**
  45468. * Define the instrumented engine.
  45469. */
  45470. engine: Engine;
  45471. private _captureGPUFrameTime;
  45472. private _gpuFrameTimeToken;
  45473. private _gpuFrameTime;
  45474. private _captureShaderCompilationTime;
  45475. private _shaderCompilationTime;
  45476. private _onBeginFrameObserver;
  45477. private _onEndFrameObserver;
  45478. private _onBeforeShaderCompilationObserver;
  45479. private _onAfterShaderCompilationObserver;
  45480. /**
  45481. * Gets the perf counter used for GPU frame time
  45482. */
  45483. readonly gpuFrameTimeCounter: PerfCounter;
  45484. /**
  45485. * Gets the GPU frame time capture status
  45486. */
  45487. /**
  45488. * Enable or disable the GPU frame time capture
  45489. */
  45490. captureGPUFrameTime: boolean;
  45491. /**
  45492. * Gets the perf counter used for shader compilation time
  45493. */
  45494. readonly shaderCompilationTimeCounter: PerfCounter;
  45495. /**
  45496. * Gets the shader compilation time capture status
  45497. */
  45498. /**
  45499. * Enable or disable the shader compilation time capture
  45500. */
  45501. captureShaderCompilationTime: boolean;
  45502. /**
  45503. * Instantiates a new engine instrumentation.
  45504. * This class can be used to get instrumentation data from a Babylon engine
  45505. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45506. * @param engine Defines the engine to instrument
  45507. */
  45508. constructor(
  45509. /**
  45510. * Define the instrumented engine.
  45511. */
  45512. engine: Engine);
  45513. /**
  45514. * Dispose and release associated resources.
  45515. */
  45516. dispose(): void;
  45517. }
  45518. }
  45519. declare module BABYLON {
  45520. /**
  45521. * This class can be used to get instrumentation data from a Babylon engine
  45522. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45523. */
  45524. export class SceneInstrumentation implements IDisposable {
  45525. /**
  45526. * Defines the scene to instrument
  45527. */
  45528. scene: Scene;
  45529. private _captureActiveMeshesEvaluationTime;
  45530. private _activeMeshesEvaluationTime;
  45531. private _captureRenderTargetsRenderTime;
  45532. private _renderTargetsRenderTime;
  45533. private _captureFrameTime;
  45534. private _frameTime;
  45535. private _captureRenderTime;
  45536. private _renderTime;
  45537. private _captureInterFrameTime;
  45538. private _interFrameTime;
  45539. private _captureParticlesRenderTime;
  45540. private _particlesRenderTime;
  45541. private _captureSpritesRenderTime;
  45542. private _spritesRenderTime;
  45543. private _capturePhysicsTime;
  45544. private _physicsTime;
  45545. private _captureAnimationsTime;
  45546. private _animationsTime;
  45547. private _captureCameraRenderTime;
  45548. private _cameraRenderTime;
  45549. private _onBeforeActiveMeshesEvaluationObserver;
  45550. private _onAfterActiveMeshesEvaluationObserver;
  45551. private _onBeforeRenderTargetsRenderObserver;
  45552. private _onAfterRenderTargetsRenderObserver;
  45553. private _onAfterRenderObserver;
  45554. private _onBeforeDrawPhaseObserver;
  45555. private _onAfterDrawPhaseObserver;
  45556. private _onBeforeAnimationsObserver;
  45557. private _onBeforeParticlesRenderingObserver;
  45558. private _onAfterParticlesRenderingObserver;
  45559. private _onBeforeSpritesRenderingObserver;
  45560. private _onAfterSpritesRenderingObserver;
  45561. private _onBeforePhysicsObserver;
  45562. private _onAfterPhysicsObserver;
  45563. private _onAfterAnimationsObserver;
  45564. private _onBeforeCameraRenderObserver;
  45565. private _onAfterCameraRenderObserver;
  45566. /**
  45567. * Gets the perf counter used for active meshes evaluation time
  45568. */
  45569. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45570. /**
  45571. * Gets the active meshes evaluation time capture status
  45572. */
  45573. /**
  45574. * Enable or disable the active meshes evaluation time capture
  45575. */
  45576. captureActiveMeshesEvaluationTime: boolean;
  45577. /**
  45578. * Gets the perf counter used for render targets render time
  45579. */
  45580. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45581. /**
  45582. * Gets the render targets render time capture status
  45583. */
  45584. /**
  45585. * Enable or disable the render targets render time capture
  45586. */
  45587. captureRenderTargetsRenderTime: boolean;
  45588. /**
  45589. * Gets the perf counter used for particles render time
  45590. */
  45591. readonly particlesRenderTimeCounter: PerfCounter;
  45592. /**
  45593. * Gets the particles render time capture status
  45594. */
  45595. /**
  45596. * Enable or disable the particles render time capture
  45597. */
  45598. captureParticlesRenderTime: boolean;
  45599. /**
  45600. * Gets the perf counter used for sprites render time
  45601. */
  45602. readonly spritesRenderTimeCounter: PerfCounter;
  45603. /**
  45604. * Gets the sprites render time capture status
  45605. */
  45606. /**
  45607. * Enable or disable the sprites render time capture
  45608. */
  45609. captureSpritesRenderTime: boolean;
  45610. /**
  45611. * Gets the perf counter used for physics time
  45612. */
  45613. readonly physicsTimeCounter: PerfCounter;
  45614. /**
  45615. * Gets the physics time capture status
  45616. */
  45617. /**
  45618. * Enable or disable the physics time capture
  45619. */
  45620. capturePhysicsTime: boolean;
  45621. /**
  45622. * Gets the perf counter used for animations time
  45623. */
  45624. readonly animationsTimeCounter: PerfCounter;
  45625. /**
  45626. * Gets the animations time capture status
  45627. */
  45628. /**
  45629. * Enable or disable the animations time capture
  45630. */
  45631. captureAnimationsTime: boolean;
  45632. /**
  45633. * Gets the perf counter used for frame time capture
  45634. */
  45635. readonly frameTimeCounter: PerfCounter;
  45636. /**
  45637. * Gets the frame time capture status
  45638. */
  45639. /**
  45640. * Enable or disable the frame time capture
  45641. */
  45642. captureFrameTime: boolean;
  45643. /**
  45644. * Gets the perf counter used for inter-frames time capture
  45645. */
  45646. readonly interFrameTimeCounter: PerfCounter;
  45647. /**
  45648. * Gets the inter-frames time capture status
  45649. */
  45650. /**
  45651. * Enable or disable the inter-frames time capture
  45652. */
  45653. captureInterFrameTime: boolean;
  45654. /**
  45655. * Gets the perf counter used for render time capture
  45656. */
  45657. readonly renderTimeCounter: PerfCounter;
  45658. /**
  45659. * Gets the render time capture status
  45660. */
  45661. /**
  45662. * Enable or disable the render time capture
  45663. */
  45664. captureRenderTime: boolean;
  45665. /**
  45666. * Gets the perf counter used for camera render time capture
  45667. */
  45668. readonly cameraRenderTimeCounter: PerfCounter;
  45669. /**
  45670. * Gets the camera render time capture status
  45671. */
  45672. /**
  45673. * Enable or disable the camera render time capture
  45674. */
  45675. captureCameraRenderTime: boolean;
  45676. /**
  45677. * Gets the perf counter used for draw calls
  45678. */
  45679. readonly drawCallsCounter: PerfCounter;
  45680. /**
  45681. * Gets the perf counter used for texture collisions
  45682. */
  45683. readonly textureCollisionsCounter: PerfCounter;
  45684. /**
  45685. * Instantiates a new scene instrumentation.
  45686. * This class can be used to get instrumentation data from a Babylon engine
  45687. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45688. * @param scene Defines the scene to instrument
  45689. */
  45690. constructor(
  45691. /**
  45692. * Defines the scene to instrument
  45693. */
  45694. scene: Scene);
  45695. /**
  45696. * Dispose and release associated resources.
  45697. */
  45698. dispose(): void;
  45699. }
  45700. }
  45701. declare module BABYLON {
  45702. /** @hidden */
  45703. export var glowMapGenerationPixelShader: {
  45704. name: string;
  45705. shader: string;
  45706. };
  45707. }
  45708. declare module BABYLON {
  45709. /** @hidden */
  45710. export var glowMapGenerationVertexShader: {
  45711. name: string;
  45712. shader: string;
  45713. };
  45714. }
  45715. declare module BABYLON {
  45716. /**
  45717. * Effect layer options. This helps customizing the behaviour
  45718. * of the effect layer.
  45719. */
  45720. export interface IEffectLayerOptions {
  45721. /**
  45722. * Multiplication factor apply to the canvas size to compute the render target size
  45723. * used to generated the objects (the smaller the faster).
  45724. */
  45725. mainTextureRatio: number;
  45726. /**
  45727. * Enforces a fixed size texture to ensure effect stability across devices.
  45728. */
  45729. mainTextureFixedSize?: number;
  45730. /**
  45731. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  45732. */
  45733. alphaBlendingMode: number;
  45734. /**
  45735. * The camera attached to the layer.
  45736. */
  45737. camera: Nullable<Camera>;
  45738. /**
  45739. * The rendering group to draw the layer in.
  45740. */
  45741. renderingGroupId: number;
  45742. }
  45743. /**
  45744. * The effect layer Helps adding post process effect blended with the main pass.
  45745. *
  45746. * This can be for instance use to generate glow or higlight effects on the scene.
  45747. *
  45748. * The effect layer class can not be used directly and is intented to inherited from to be
  45749. * customized per effects.
  45750. */
  45751. export abstract class EffectLayer {
  45752. private _vertexBuffers;
  45753. private _indexBuffer;
  45754. private _cachedDefines;
  45755. private _effectLayerMapGenerationEffect;
  45756. private _effectLayerOptions;
  45757. private _mergeEffect;
  45758. protected _scene: Scene;
  45759. protected _engine: Engine;
  45760. protected _maxSize: number;
  45761. protected _mainTextureDesiredSize: ISize;
  45762. protected _mainTexture: RenderTargetTexture;
  45763. protected _shouldRender: boolean;
  45764. protected _postProcesses: PostProcess[];
  45765. protected _textures: BaseTexture[];
  45766. protected _emissiveTextureAndColor: {
  45767. texture: Nullable<BaseTexture>;
  45768. color: Color4;
  45769. };
  45770. /**
  45771. * The name of the layer
  45772. */
  45773. name: string;
  45774. /**
  45775. * The clear color of the texture used to generate the glow map.
  45776. */
  45777. neutralColor: Color4;
  45778. /**
  45779. * Specifies wether the highlight layer is enabled or not.
  45780. */
  45781. isEnabled: boolean;
  45782. /**
  45783. * Gets the camera attached to the layer.
  45784. */
  45785. readonly camera: Nullable<Camera>;
  45786. /**
  45787. * Gets the rendering group id the layer should render in.
  45788. */
  45789. readonly renderingGroupId: number;
  45790. /**
  45791. * An event triggered when the effect layer has been disposed.
  45792. */
  45793. onDisposeObservable: Observable<EffectLayer>;
  45794. /**
  45795. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  45796. */
  45797. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  45798. /**
  45799. * An event triggered when the generated texture is being merged in the scene.
  45800. */
  45801. onBeforeComposeObservable: Observable<EffectLayer>;
  45802. /**
  45803. * An event triggered when the generated texture has been merged in the scene.
  45804. */
  45805. onAfterComposeObservable: Observable<EffectLayer>;
  45806. /**
  45807. * An event triggered when the efffect layer changes its size.
  45808. */
  45809. onSizeChangedObservable: Observable<EffectLayer>;
  45810. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  45811. /**
  45812. * Instantiates a new effect Layer and references it in the scene.
  45813. * @param name The name of the layer
  45814. * @param scene The scene to use the layer in
  45815. */
  45816. constructor(
  45817. /** The Friendly of the effect in the scene */
  45818. name: string, scene: Scene);
  45819. /**
  45820. * Get the effect name of the layer.
  45821. * @return The effect name
  45822. */
  45823. abstract getEffectName(): string;
  45824. /**
  45825. * Checks for the readiness of the element composing the layer.
  45826. * @param subMesh the mesh to check for
  45827. * @param useInstances specify wether or not to use instances to render the mesh
  45828. * @return true if ready otherwise, false
  45829. */
  45830. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45831. /**
  45832. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45833. * @returns true if the effect requires stencil during the main canvas render pass.
  45834. */
  45835. abstract needStencil(): boolean;
  45836. /**
  45837. * Create the merge effect. This is the shader use to blit the information back
  45838. * to the main canvas at the end of the scene rendering.
  45839. * @returns The effect containing the shader used to merge the effect on the main canvas
  45840. */
  45841. protected abstract _createMergeEffect(): Effect;
  45842. /**
  45843. * Creates the render target textures and post processes used in the effect layer.
  45844. */
  45845. protected abstract _createTextureAndPostProcesses(): void;
  45846. /**
  45847. * Implementation specific of rendering the generating effect on the main canvas.
  45848. * @param effect The effect used to render through
  45849. */
  45850. protected abstract _internalRender(effect: Effect): void;
  45851. /**
  45852. * Sets the required values for both the emissive texture and and the main color.
  45853. */
  45854. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45855. /**
  45856. * Free any resources and references associated to a mesh.
  45857. * Internal use
  45858. * @param mesh The mesh to free.
  45859. */
  45860. abstract _disposeMesh(mesh: Mesh): void;
  45861. /**
  45862. * Serializes this layer (Glow or Highlight for example)
  45863. * @returns a serialized layer object
  45864. */
  45865. abstract serialize?(): any;
  45866. /**
  45867. * Initializes the effect layer with the required options.
  45868. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  45869. */
  45870. protected _init(options: Partial<IEffectLayerOptions>): void;
  45871. /**
  45872. * Generates the index buffer of the full screen quad blending to the main canvas.
  45873. */
  45874. private _generateIndexBuffer;
  45875. /**
  45876. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  45877. */
  45878. private _genrateVertexBuffer;
  45879. /**
  45880. * Sets the main texture desired size which is the closest power of two
  45881. * of the engine canvas size.
  45882. */
  45883. private _setMainTextureSize;
  45884. /**
  45885. * Creates the main texture for the effect layer.
  45886. */
  45887. protected _createMainTexture(): void;
  45888. /**
  45889. * Adds specific effects defines.
  45890. * @param defines The defines to add specifics to.
  45891. */
  45892. protected _addCustomEffectDefines(defines: string[]): void;
  45893. /**
  45894. * Checks for the readiness of the element composing the layer.
  45895. * @param subMesh the mesh to check for
  45896. * @param useInstances specify wether or not to use instances to render the mesh
  45897. * @param emissiveTexture the associated emissive texture used to generate the glow
  45898. * @return true if ready otherwise, false
  45899. */
  45900. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  45901. /**
  45902. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  45903. */
  45904. render(): void;
  45905. /**
  45906. * Determine if a given mesh will be used in the current effect.
  45907. * @param mesh mesh to test
  45908. * @returns true if the mesh will be used
  45909. */
  45910. hasMesh(mesh: AbstractMesh): boolean;
  45911. /**
  45912. * Returns true if the layer contains information to display, otherwise false.
  45913. * @returns true if the glow layer should be rendered
  45914. */
  45915. shouldRender(): boolean;
  45916. /**
  45917. * Returns true if the mesh should render, otherwise false.
  45918. * @param mesh The mesh to render
  45919. * @returns true if it should render otherwise false
  45920. */
  45921. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  45922. /**
  45923. * Returns true if the mesh can be rendered, otherwise false.
  45924. * @param mesh The mesh to render
  45925. * @param material The material used on the mesh
  45926. * @returns true if it can be rendered otherwise false
  45927. */
  45928. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45929. /**
  45930. * Returns true if the mesh should render, otherwise false.
  45931. * @param mesh The mesh to render
  45932. * @returns true if it should render otherwise false
  45933. */
  45934. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  45935. /**
  45936. * Renders the submesh passed in parameter to the generation map.
  45937. */
  45938. protected _renderSubMesh(subMesh: SubMesh): void;
  45939. /**
  45940. * Rebuild the required buffers.
  45941. * @hidden Internal use only.
  45942. */ rebuild(): void;
  45943. /**
  45944. * Dispose only the render target textures and post process.
  45945. */
  45946. private _disposeTextureAndPostProcesses;
  45947. /**
  45948. * Dispose the highlight layer and free resources.
  45949. */
  45950. dispose(): void;
  45951. /**
  45952. * Gets the class name of the effect layer
  45953. * @returns the string with the class name of the effect layer
  45954. */
  45955. getClassName(): string;
  45956. /**
  45957. * Creates an effect layer from parsed effect layer data
  45958. * @param parsedEffectLayer defines effect layer data
  45959. * @param scene defines the current scene
  45960. * @param rootUrl defines the root URL containing the effect layer information
  45961. * @returns a parsed effect Layer
  45962. */
  45963. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  45964. }
  45965. }
  45966. declare module BABYLON {
  45967. interface AbstractScene {
  45968. /**
  45969. * The list of effect layers (highlights/glow) added to the scene
  45970. * @see http://doc.babylonjs.com/how_to/highlight_layer
  45971. * @see http://doc.babylonjs.com/how_to/glow_layer
  45972. */
  45973. effectLayers: Array<EffectLayer>;
  45974. /**
  45975. * Removes the given effect layer from this scene.
  45976. * @param toRemove defines the effect layer to remove
  45977. * @returns the index of the removed effect layer
  45978. */
  45979. removeEffectLayer(toRemove: EffectLayer): number;
  45980. /**
  45981. * Adds the given effect layer to this scene
  45982. * @param newEffectLayer defines the effect layer to add
  45983. */
  45984. addEffectLayer(newEffectLayer: EffectLayer): void;
  45985. }
  45986. /**
  45987. * Defines the layer scene component responsible to manage any effect layers
  45988. * in a given scene.
  45989. */
  45990. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  45991. /**
  45992. * The component name helpfull to identify the component in the list of scene components.
  45993. */
  45994. readonly name: string;
  45995. /**
  45996. * The scene the component belongs to.
  45997. */
  45998. scene: Scene;
  45999. private _engine;
  46000. private _renderEffects;
  46001. private _needStencil;
  46002. private _previousStencilState;
  46003. /**
  46004. * Creates a new instance of the component for the given scene
  46005. * @param scene Defines the scene to register the component in
  46006. */
  46007. constructor(scene: Scene);
  46008. /**
  46009. * Registers the component in a given scene
  46010. */
  46011. register(): void;
  46012. /**
  46013. * Rebuilds the elements related to this component in case of
  46014. * context lost for instance.
  46015. */
  46016. rebuild(): void;
  46017. /**
  46018. * Serializes the component data to the specified json object
  46019. * @param serializationObject The object to serialize to
  46020. */
  46021. serialize(serializationObject: any): void;
  46022. /**
  46023. * Adds all the element from the container to the scene
  46024. * @param container the container holding the elements
  46025. */
  46026. addFromContainer(container: AbstractScene): void;
  46027. /**
  46028. * Removes all the elements in the container from the scene
  46029. * @param container contains the elements to remove
  46030. * @param dispose if the removed element should be disposed (default: false)
  46031. */
  46032. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46033. /**
  46034. * Disposes the component and the associated ressources.
  46035. */
  46036. dispose(): void;
  46037. private _isReadyForMesh;
  46038. private _renderMainTexture;
  46039. private _setStencil;
  46040. private _setStencilBack;
  46041. private _draw;
  46042. private _drawCamera;
  46043. private _drawRenderingGroup;
  46044. }
  46045. }
  46046. declare module BABYLON {
  46047. /** @hidden */
  46048. export var glowMapMergePixelShader: {
  46049. name: string;
  46050. shader: string;
  46051. };
  46052. }
  46053. declare module BABYLON {
  46054. /** @hidden */
  46055. export var glowMapMergeVertexShader: {
  46056. name: string;
  46057. shader: string;
  46058. };
  46059. }
  46060. declare module BABYLON {
  46061. interface AbstractScene {
  46062. /**
  46063. * Return a the first highlight layer of the scene with a given name.
  46064. * @param name The name of the highlight layer to look for.
  46065. * @return The highlight layer if found otherwise null.
  46066. */
  46067. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46068. }
  46069. /**
  46070. * Glow layer options. This helps customizing the behaviour
  46071. * of the glow layer.
  46072. */
  46073. export interface IGlowLayerOptions {
  46074. /**
  46075. * Multiplication factor apply to the canvas size to compute the render target size
  46076. * used to generated the glowing objects (the smaller the faster).
  46077. */
  46078. mainTextureRatio: number;
  46079. /**
  46080. * Enforces a fixed size texture to ensure resize independant blur.
  46081. */
  46082. mainTextureFixedSize?: number;
  46083. /**
  46084. * How big is the kernel of the blur texture.
  46085. */
  46086. blurKernelSize: number;
  46087. /**
  46088. * The camera attached to the layer.
  46089. */
  46090. camera: Nullable<Camera>;
  46091. /**
  46092. * Enable MSAA by chosing the number of samples.
  46093. */
  46094. mainTextureSamples?: number;
  46095. /**
  46096. * The rendering group to draw the layer in.
  46097. */
  46098. renderingGroupId: number;
  46099. }
  46100. /**
  46101. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46102. *
  46103. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46104. * glowy meshes to your scene.
  46105. *
  46106. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46107. */
  46108. export class GlowLayer extends EffectLayer {
  46109. /**
  46110. * Effect Name of the layer.
  46111. */
  46112. static readonly EffectName: string;
  46113. /**
  46114. * The default blur kernel size used for the glow.
  46115. */
  46116. static DefaultBlurKernelSize: number;
  46117. /**
  46118. * The default texture size ratio used for the glow.
  46119. */
  46120. static DefaultTextureRatio: number;
  46121. /**
  46122. * Sets the kernel size of the blur.
  46123. */
  46124. /**
  46125. * Gets the kernel size of the blur.
  46126. */
  46127. blurKernelSize: number;
  46128. /**
  46129. * Sets the glow intensity.
  46130. */
  46131. /**
  46132. * Gets the glow intensity.
  46133. */
  46134. intensity: number;
  46135. private _options;
  46136. private _intensity;
  46137. private _horizontalBlurPostprocess1;
  46138. private _verticalBlurPostprocess1;
  46139. private _horizontalBlurPostprocess2;
  46140. private _verticalBlurPostprocess2;
  46141. private _blurTexture1;
  46142. private _blurTexture2;
  46143. private _postProcesses1;
  46144. private _postProcesses2;
  46145. private _includedOnlyMeshes;
  46146. private _excludedMeshes;
  46147. /**
  46148. * Callback used to let the user override the color selection on a per mesh basis
  46149. */
  46150. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46151. /**
  46152. * Callback used to let the user override the texture selection on a per mesh basis
  46153. */
  46154. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46155. /**
  46156. * Instantiates a new glow Layer and references it to the scene.
  46157. * @param name The name of the layer
  46158. * @param scene The scene to use the layer in
  46159. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46160. */
  46161. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46162. /**
  46163. * Get the effect name of the layer.
  46164. * @return The effect name
  46165. */
  46166. getEffectName(): string;
  46167. /**
  46168. * Create the merge effect. This is the shader use to blit the information back
  46169. * to the main canvas at the end of the scene rendering.
  46170. */
  46171. protected _createMergeEffect(): Effect;
  46172. /**
  46173. * Creates the render target textures and post processes used in the glow layer.
  46174. */
  46175. protected _createTextureAndPostProcesses(): void;
  46176. /**
  46177. * Checks for the readiness of the element composing the layer.
  46178. * @param subMesh the mesh to check for
  46179. * @param useInstances specify wether or not to use instances to render the mesh
  46180. * @param emissiveTexture the associated emissive texture used to generate the glow
  46181. * @return true if ready otherwise, false
  46182. */
  46183. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46184. /**
  46185. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46186. */
  46187. needStencil(): boolean;
  46188. /**
  46189. * Returns true if the mesh can be rendered, otherwise false.
  46190. * @param mesh The mesh to render
  46191. * @param material The material used on the mesh
  46192. * @returns true if it can be rendered otherwise false
  46193. */
  46194. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46195. /**
  46196. * Implementation specific of rendering the generating effect on the main canvas.
  46197. * @param effect The effect used to render through
  46198. */
  46199. protected _internalRender(effect: Effect): void;
  46200. /**
  46201. * Sets the required values for both the emissive texture and and the main color.
  46202. */
  46203. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46204. /**
  46205. * Returns true if the mesh should render, otherwise false.
  46206. * @param mesh The mesh to render
  46207. * @returns true if it should render otherwise false
  46208. */
  46209. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46210. /**
  46211. * Adds specific effects defines.
  46212. * @param defines The defines to add specifics to.
  46213. */
  46214. protected _addCustomEffectDefines(defines: string[]): void;
  46215. /**
  46216. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46217. * @param mesh The mesh to exclude from the glow layer
  46218. */
  46219. addExcludedMesh(mesh: Mesh): void;
  46220. /**
  46221. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46222. * @param mesh The mesh to remove
  46223. */
  46224. removeExcludedMesh(mesh: Mesh): void;
  46225. /**
  46226. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46227. * @param mesh The mesh to include in the glow layer
  46228. */
  46229. addIncludedOnlyMesh(mesh: Mesh): void;
  46230. /**
  46231. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46232. * @param mesh The mesh to remove
  46233. */
  46234. removeIncludedOnlyMesh(mesh: Mesh): void;
  46235. /**
  46236. * Determine if a given mesh will be used in the glow layer
  46237. * @param mesh The mesh to test
  46238. * @returns true if the mesh will be highlighted by the current glow layer
  46239. */
  46240. hasMesh(mesh: AbstractMesh): boolean;
  46241. /**
  46242. * Free any resources and references associated to a mesh.
  46243. * Internal use
  46244. * @param mesh The mesh to free.
  46245. * @hidden
  46246. */ disposeMesh(mesh: Mesh): void;
  46247. /**
  46248. * Gets the class name of the effect layer
  46249. * @returns the string with the class name of the effect layer
  46250. */
  46251. getClassName(): string;
  46252. /**
  46253. * Serializes this glow layer
  46254. * @returns a serialized glow layer object
  46255. */
  46256. serialize(): any;
  46257. /**
  46258. * Creates a Glow Layer from parsed glow layer data
  46259. * @param parsedGlowLayer defines glow layer data
  46260. * @param scene defines the current scene
  46261. * @param rootUrl defines the root URL containing the glow layer information
  46262. * @returns a parsed Glow Layer
  46263. */
  46264. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46265. }
  46266. }
  46267. declare module BABYLON {
  46268. /** @hidden */
  46269. export var glowBlurPostProcessPixelShader: {
  46270. name: string;
  46271. shader: string;
  46272. };
  46273. }
  46274. declare module BABYLON {
  46275. interface AbstractScene {
  46276. /**
  46277. * Return a the first highlight layer of the scene with a given name.
  46278. * @param name The name of the highlight layer to look for.
  46279. * @return The highlight layer if found otherwise null.
  46280. */
  46281. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46282. }
  46283. /**
  46284. * Highlight layer options. This helps customizing the behaviour
  46285. * of the highlight layer.
  46286. */
  46287. export interface IHighlightLayerOptions {
  46288. /**
  46289. * Multiplication factor apply to the canvas size to compute the render target size
  46290. * used to generated the glowing objects (the smaller the faster).
  46291. */
  46292. mainTextureRatio: number;
  46293. /**
  46294. * Enforces a fixed size texture to ensure resize independant blur.
  46295. */
  46296. mainTextureFixedSize?: number;
  46297. /**
  46298. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46299. * of the picture to blur (the smaller the faster).
  46300. */
  46301. blurTextureSizeRatio: number;
  46302. /**
  46303. * How big in texel of the blur texture is the vertical blur.
  46304. */
  46305. blurVerticalSize: number;
  46306. /**
  46307. * How big in texel of the blur texture is the horizontal blur.
  46308. */
  46309. blurHorizontalSize: number;
  46310. /**
  46311. * Alpha blending mode used to apply the blur. Default is combine.
  46312. */
  46313. alphaBlendingMode: number;
  46314. /**
  46315. * The camera attached to the layer.
  46316. */
  46317. camera: Nullable<Camera>;
  46318. /**
  46319. * Should we display highlight as a solid stroke?
  46320. */
  46321. isStroke?: boolean;
  46322. /**
  46323. * The rendering group to draw the layer in.
  46324. */
  46325. renderingGroupId: number;
  46326. }
  46327. /**
  46328. * The highlight layer Helps adding a glow effect around a mesh.
  46329. *
  46330. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46331. * glowy meshes to your scene.
  46332. *
  46333. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46334. */
  46335. export class HighlightLayer extends EffectLayer {
  46336. name: string;
  46337. /**
  46338. * Effect Name of the highlight layer.
  46339. */
  46340. static readonly EffectName: string;
  46341. /**
  46342. * The neutral color used during the preparation of the glow effect.
  46343. * This is black by default as the blend operation is a blend operation.
  46344. */
  46345. static NeutralColor: Color4;
  46346. /**
  46347. * Stencil value used for glowing meshes.
  46348. */
  46349. static GlowingMeshStencilReference: number;
  46350. /**
  46351. * Stencil value used for the other meshes in the scene.
  46352. */
  46353. static NormalMeshStencilReference: number;
  46354. /**
  46355. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46356. */
  46357. innerGlow: boolean;
  46358. /**
  46359. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46360. */
  46361. outerGlow: boolean;
  46362. /**
  46363. * Specifies the horizontal size of the blur.
  46364. */
  46365. /**
  46366. * Gets the horizontal size of the blur.
  46367. */
  46368. blurHorizontalSize: number;
  46369. /**
  46370. * Specifies the vertical size of the blur.
  46371. */
  46372. /**
  46373. * Gets the vertical size of the blur.
  46374. */
  46375. blurVerticalSize: number;
  46376. /**
  46377. * An event triggered when the highlight layer is being blurred.
  46378. */
  46379. onBeforeBlurObservable: Observable<HighlightLayer>;
  46380. /**
  46381. * An event triggered when the highlight layer has been blurred.
  46382. */
  46383. onAfterBlurObservable: Observable<HighlightLayer>;
  46384. private _instanceGlowingMeshStencilReference;
  46385. private _options;
  46386. private _downSamplePostprocess;
  46387. private _horizontalBlurPostprocess;
  46388. private _verticalBlurPostprocess;
  46389. private _blurTexture;
  46390. private _meshes;
  46391. private _excludedMeshes;
  46392. /**
  46393. * Instantiates a new highlight Layer and references it to the scene..
  46394. * @param name The name of the layer
  46395. * @param scene The scene to use the layer in
  46396. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46397. */
  46398. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46399. /**
  46400. * Get the effect name of the layer.
  46401. * @return The effect name
  46402. */
  46403. getEffectName(): string;
  46404. /**
  46405. * Create the merge effect. This is the shader use to blit the information back
  46406. * to the main canvas at the end of the scene rendering.
  46407. */
  46408. protected _createMergeEffect(): Effect;
  46409. /**
  46410. * Creates the render target textures and post processes used in the highlight layer.
  46411. */
  46412. protected _createTextureAndPostProcesses(): void;
  46413. /**
  46414. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46415. */
  46416. needStencil(): boolean;
  46417. /**
  46418. * Checks for the readiness of the element composing the layer.
  46419. * @param subMesh the mesh to check for
  46420. * @param useInstances specify wether or not to use instances to render the mesh
  46421. * @param emissiveTexture the associated emissive texture used to generate the glow
  46422. * @return true if ready otherwise, false
  46423. */
  46424. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46425. /**
  46426. * Implementation specific of rendering the generating effect on the main canvas.
  46427. * @param effect The effect used to render through
  46428. */
  46429. protected _internalRender(effect: Effect): void;
  46430. /**
  46431. * Returns true if the layer contains information to display, otherwise false.
  46432. */
  46433. shouldRender(): boolean;
  46434. /**
  46435. * Returns true if the mesh should render, otherwise false.
  46436. * @param mesh The mesh to render
  46437. * @returns true if it should render otherwise false
  46438. */
  46439. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46440. /**
  46441. * Sets the required values for both the emissive texture and and the main color.
  46442. */
  46443. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46444. /**
  46445. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46446. * @param mesh The mesh to exclude from the highlight layer
  46447. */
  46448. addExcludedMesh(mesh: Mesh): void;
  46449. /**
  46450. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46451. * @param mesh The mesh to highlight
  46452. */
  46453. removeExcludedMesh(mesh: Mesh): void;
  46454. /**
  46455. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46456. * @param mesh mesh to test
  46457. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46458. */
  46459. hasMesh(mesh: AbstractMesh): boolean;
  46460. /**
  46461. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46462. * @param mesh The mesh to highlight
  46463. * @param color The color of the highlight
  46464. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46465. */
  46466. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46467. /**
  46468. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46469. * @param mesh The mesh to highlight
  46470. */
  46471. removeMesh(mesh: Mesh): void;
  46472. /**
  46473. * Force the stencil to the normal expected value for none glowing parts
  46474. */
  46475. private _defaultStencilReference;
  46476. /**
  46477. * Free any resources and references associated to a mesh.
  46478. * Internal use
  46479. * @param mesh The mesh to free.
  46480. * @hidden
  46481. */ disposeMesh(mesh: Mesh): void;
  46482. /**
  46483. * Dispose the highlight layer and free resources.
  46484. */
  46485. dispose(): void;
  46486. /**
  46487. * Gets the class name of the effect layer
  46488. * @returns the string with the class name of the effect layer
  46489. */
  46490. getClassName(): string;
  46491. /**
  46492. * Serializes this Highlight layer
  46493. * @returns a serialized Highlight layer object
  46494. */
  46495. serialize(): any;
  46496. /**
  46497. * Creates a Highlight layer from parsed Highlight layer data
  46498. * @param parsedHightlightLayer defines the Highlight layer data
  46499. * @param scene defines the current scene
  46500. * @param rootUrl defines the root URL containing the Highlight layer information
  46501. * @returns a parsed Highlight layer
  46502. */
  46503. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46504. }
  46505. }
  46506. declare module BABYLON {
  46507. /** @hidden */
  46508. export var lensFlarePixelShader: {
  46509. name: string;
  46510. shader: string;
  46511. };
  46512. }
  46513. declare module BABYLON {
  46514. /** @hidden */
  46515. export var lensFlareVertexShader: {
  46516. name: string;
  46517. shader: string;
  46518. };
  46519. }
  46520. declare module BABYLON {
  46521. /**
  46522. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46523. * It is usually composed of several `lensFlare`.
  46524. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46525. */
  46526. export class LensFlareSystem {
  46527. /**
  46528. * Define the name of the lens flare system
  46529. */
  46530. name: string;
  46531. /**
  46532. * List of lens flares used in this system.
  46533. */
  46534. lensFlares: LensFlare[];
  46535. /**
  46536. * Define a limit from the border the lens flare can be visible.
  46537. */
  46538. borderLimit: number;
  46539. /**
  46540. * Define a viewport border we do not want to see the lens flare in.
  46541. */
  46542. viewportBorder: number;
  46543. /**
  46544. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46545. */
  46546. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46547. /**
  46548. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46549. */
  46550. layerMask: number;
  46551. /**
  46552. * Define the id of the lens flare system in the scene.
  46553. * (equal to name by default)
  46554. */
  46555. id: string;
  46556. private _scene;
  46557. private _emitter;
  46558. private _vertexBuffers;
  46559. private _indexBuffer;
  46560. private _effect;
  46561. private _positionX;
  46562. private _positionY;
  46563. private _isEnabled;
  46564. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  46565. /**
  46566. * Instantiates a lens flare system.
  46567. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46568. * It is usually composed of several `lensFlare`.
  46569. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46570. * @param name Define the name of the lens flare system in the scene
  46571. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46572. * @param scene Define the scene the lens flare system belongs to
  46573. */
  46574. constructor(
  46575. /**
  46576. * Define the name of the lens flare system
  46577. */
  46578. name: string, emitter: any, scene: Scene);
  46579. /**
  46580. * Define if the lens flare system is enabled.
  46581. */
  46582. isEnabled: boolean;
  46583. /**
  46584. * Get the scene the effects belongs to.
  46585. * @returns the scene holding the lens flare system
  46586. */
  46587. getScene(): Scene;
  46588. /**
  46589. * Get the emitter of the lens flare system.
  46590. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46591. * @returns the emitter of the lens flare system
  46592. */
  46593. getEmitter(): any;
  46594. /**
  46595. * Set the emitter of the lens flare system.
  46596. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46597. * @param newEmitter Define the new emitter of the system
  46598. */
  46599. setEmitter(newEmitter: any): void;
  46600. /**
  46601. * Get the lens flare system emitter position.
  46602. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46603. * @returns the position
  46604. */
  46605. getEmitterPosition(): Vector3;
  46606. /**
  46607. * @hidden
  46608. */
  46609. computeEffectivePosition(globalViewport: Viewport): boolean;
  46610. /** @hidden */ isVisible(): boolean;
  46611. /**
  46612. * @hidden
  46613. */
  46614. render(): boolean;
  46615. /**
  46616. * Dispose and release the lens flare with its associated resources.
  46617. */
  46618. dispose(): void;
  46619. /**
  46620. * Parse a lens flare system from a JSON repressentation
  46621. * @param parsedLensFlareSystem Define the JSON to parse
  46622. * @param scene Define the scene the parsed system should be instantiated in
  46623. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46624. * @returns the parsed system
  46625. */
  46626. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46627. /**
  46628. * Serialize the current Lens Flare System into a JSON representation.
  46629. * @returns the serialized JSON
  46630. */
  46631. serialize(): any;
  46632. }
  46633. }
  46634. declare module BABYLON {
  46635. /**
  46636. * This represents one of the lens effect in a `lensFlareSystem`.
  46637. * It controls one of the indiviual texture used in the effect.
  46638. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46639. */
  46640. export class LensFlare {
  46641. /**
  46642. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46643. */
  46644. size: number;
  46645. /**
  46646. * 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.
  46647. */
  46648. position: number;
  46649. /**
  46650. * Define the lens color.
  46651. */
  46652. color: Color3;
  46653. /**
  46654. * Define the lens texture.
  46655. */
  46656. texture: Nullable<Texture>;
  46657. /**
  46658. * Define the alpha mode to render this particular lens.
  46659. */
  46660. alphaMode: number;
  46661. private _system;
  46662. /**
  46663. * Creates a new Lens Flare.
  46664. * This represents one of the lens effect in a `lensFlareSystem`.
  46665. * It controls one of the indiviual texture used in the effect.
  46666. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46667. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46668. * @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.
  46669. * @param color Define the lens color
  46670. * @param imgUrl Define the lens texture url
  46671. * @param system Define the `lensFlareSystem` this flare is part of
  46672. * @returns The newly created Lens Flare
  46673. */
  46674. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46675. /**
  46676. * Instantiates a new Lens Flare.
  46677. * This represents one of the lens effect in a `lensFlareSystem`.
  46678. * It controls one of the indiviual texture used in the effect.
  46679. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46680. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46681. * @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.
  46682. * @param color Define the lens color
  46683. * @param imgUrl Define the lens texture url
  46684. * @param system Define the `lensFlareSystem` this flare is part of
  46685. */
  46686. constructor(
  46687. /**
  46688. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46689. */
  46690. size: number,
  46691. /**
  46692. * 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.
  46693. */
  46694. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46695. /**
  46696. * Dispose and release the lens flare with its associated resources.
  46697. */
  46698. dispose(): void;
  46699. }
  46700. }
  46701. declare module BABYLON {
  46702. interface AbstractScene {
  46703. /**
  46704. * The list of lens flare system added to the scene
  46705. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46706. */
  46707. lensFlareSystems: Array<LensFlareSystem>;
  46708. /**
  46709. * Removes the given lens flare system from this scene.
  46710. * @param toRemove The lens flare system to remove
  46711. * @returns The index of the removed lens flare system
  46712. */
  46713. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  46714. /**
  46715. * Adds the given lens flare system to this scene
  46716. * @param newLensFlareSystem The lens flare system to add
  46717. */
  46718. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  46719. /**
  46720. * Gets a lens flare system using its name
  46721. * @param name defines the name to look for
  46722. * @returns the lens flare system or null if not found
  46723. */
  46724. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  46725. /**
  46726. * Gets a lens flare system using its id
  46727. * @param id defines the id to look for
  46728. * @returns the lens flare system or null if not found
  46729. */
  46730. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  46731. }
  46732. /**
  46733. * Defines the lens flare scene component responsible to manage any lens flares
  46734. * in a given scene.
  46735. */
  46736. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  46737. /**
  46738. * The component name helpfull to identify the component in the list of scene components.
  46739. */
  46740. readonly name: string;
  46741. /**
  46742. * The scene the component belongs to.
  46743. */
  46744. scene: Scene;
  46745. /**
  46746. * Creates a new instance of the component for the given scene
  46747. * @param scene Defines the scene to register the component in
  46748. */
  46749. constructor(scene: Scene);
  46750. /**
  46751. * Registers the component in a given scene
  46752. */
  46753. register(): void;
  46754. /**
  46755. * Rebuilds the elements related to this component in case of
  46756. * context lost for instance.
  46757. */
  46758. rebuild(): void;
  46759. /**
  46760. * Adds all the element from the container to the scene
  46761. * @param container the container holding the elements
  46762. */
  46763. addFromContainer(container: AbstractScene): void;
  46764. /**
  46765. * Removes all the elements in the container from the scene
  46766. * @param container contains the elements to remove
  46767. * @param dispose if the removed element should be disposed (default: false)
  46768. */
  46769. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46770. /**
  46771. * Serializes the component data to the specified json object
  46772. * @param serializationObject The object to serialize to
  46773. */
  46774. serialize(serializationObject: any): void;
  46775. /**
  46776. * Disposes the component and the associated ressources.
  46777. */
  46778. dispose(): void;
  46779. private _draw;
  46780. }
  46781. }
  46782. declare module BABYLON {
  46783. /**
  46784. * Defines the shadow generator component responsible to manage any shadow generators
  46785. * in a given scene.
  46786. */
  46787. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  46788. /**
  46789. * The component name helpfull to identify the component in the list of scene components.
  46790. */
  46791. readonly name: string;
  46792. /**
  46793. * The scene the component belongs to.
  46794. */
  46795. scene: Scene;
  46796. /**
  46797. * Creates a new instance of the component for the given scene
  46798. * @param scene Defines the scene to register the component in
  46799. */
  46800. constructor(scene: Scene);
  46801. /**
  46802. * Registers the component in a given scene
  46803. */
  46804. register(): void;
  46805. /**
  46806. * Rebuilds the elements related to this component in case of
  46807. * context lost for instance.
  46808. */
  46809. rebuild(): void;
  46810. /**
  46811. * Serializes the component data to the specified json object
  46812. * @param serializationObject The object to serialize to
  46813. */
  46814. serialize(serializationObject: any): void;
  46815. /**
  46816. * Adds all the element from the container to the scene
  46817. * @param container the container holding the elements
  46818. */
  46819. addFromContainer(container: AbstractScene): void;
  46820. /**
  46821. * Removes all the elements in the container from the scene
  46822. * @param container contains the elements to remove
  46823. * @param dispose if the removed element should be disposed (default: false)
  46824. */
  46825. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46826. /**
  46827. * Rebuilds the elements related to this component in case of
  46828. * context lost for instance.
  46829. */
  46830. dispose(): void;
  46831. private _gatherRenderTargets;
  46832. }
  46833. }
  46834. declare module BABYLON {
  46835. /**
  46836. * A point light is a light defined by an unique point in world space.
  46837. * The light is emitted in every direction from this point.
  46838. * A good example of a point light is a standard light bulb.
  46839. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46840. */
  46841. export class PointLight extends ShadowLight {
  46842. private _shadowAngle;
  46843. /**
  46844. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46845. * This specifies what angle the shadow will use to be created.
  46846. *
  46847. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46848. */
  46849. /**
  46850. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46851. * This specifies what angle the shadow will use to be created.
  46852. *
  46853. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46854. */
  46855. shadowAngle: number;
  46856. /**
  46857. * Gets the direction if it has been set.
  46858. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46859. */
  46860. /**
  46861. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46862. */
  46863. direction: Vector3;
  46864. /**
  46865. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46866. * A PointLight emits the light in every direction.
  46867. * It can cast shadows.
  46868. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46869. * ```javascript
  46870. * var pointLight = new PointLight("pl", camera.position, scene);
  46871. * ```
  46872. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46873. * @param name The light friendly name
  46874. * @param position The position of the point light in the scene
  46875. * @param scene The scene the lights belongs to
  46876. */
  46877. constructor(name: string, position: Vector3, scene: Scene);
  46878. /**
  46879. * Returns the string "PointLight"
  46880. * @returns the class name
  46881. */
  46882. getClassName(): string;
  46883. /**
  46884. * Returns the integer 0.
  46885. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46886. */
  46887. getTypeID(): number;
  46888. /**
  46889. * Specifies wether or not the shadowmap should be a cube texture.
  46890. * @returns true if the shadowmap needs to be a cube texture.
  46891. */
  46892. needCube(): boolean;
  46893. /**
  46894. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  46895. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46896. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46897. */
  46898. getShadowDirection(faceIndex?: number): Vector3;
  46899. /**
  46900. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  46901. * - fov = PI / 2
  46902. * - aspect ratio : 1.0
  46903. * - z-near and far equal to the active camera minZ and maxZ.
  46904. * Returns the PointLight.
  46905. */
  46906. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46907. protected _buildUniformLayout(): void;
  46908. /**
  46909. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  46910. * @param effect The effect to update
  46911. * @param lightIndex The index of the light in the effect to update
  46912. * @returns The point light
  46913. */
  46914. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  46915. /**
  46916. * Prepares the list of defines specific to the light type.
  46917. * @param defines the list of defines
  46918. * @param lightIndex defines the index of the light for the effect
  46919. */
  46920. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46921. }
  46922. }
  46923. declare module BABYLON {
  46924. /**
  46925. * Header information of HDR texture files.
  46926. */
  46927. export interface HDRInfo {
  46928. /**
  46929. * The height of the texture in pixels.
  46930. */
  46931. height: number;
  46932. /**
  46933. * The width of the texture in pixels.
  46934. */
  46935. width: number;
  46936. /**
  46937. * The index of the beginning of the data in the binary file.
  46938. */
  46939. dataPosition: number;
  46940. }
  46941. /**
  46942. * This groups tools to convert HDR texture to native colors array.
  46943. */
  46944. export class HDRTools {
  46945. private static Ldexp;
  46946. private static Rgbe2float;
  46947. private static readStringLine;
  46948. /**
  46949. * Reads header information from an RGBE texture stored in a native array.
  46950. * More information on this format are available here:
  46951. * https://en.wikipedia.org/wiki/RGBE_image_format
  46952. *
  46953. * @param uint8array The binary file stored in native array.
  46954. * @return The header information.
  46955. */
  46956. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  46957. /**
  46958. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  46959. * This RGBE texture needs to store the information as a panorama.
  46960. *
  46961. * More information on this format are available here:
  46962. * https://en.wikipedia.org/wiki/RGBE_image_format
  46963. *
  46964. * @param buffer The binary file stored in an array buffer.
  46965. * @param size The expected size of the extracted cubemap.
  46966. * @return The Cube Map information.
  46967. */
  46968. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  46969. /**
  46970. * Returns the pixels data extracted from an RGBE texture.
  46971. * This pixels will be stored left to right up to down in the R G B order in one array.
  46972. *
  46973. * More information on this format are available here:
  46974. * https://en.wikipedia.org/wiki/RGBE_image_format
  46975. *
  46976. * @param uint8array The binary file stored in an array buffer.
  46977. * @param hdrInfo The header information of the file.
  46978. * @return The pixels data in RGB right to left up to down order.
  46979. */
  46980. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  46981. private static RGBE_ReadPixels_RLE;
  46982. }
  46983. }
  46984. declare module BABYLON {
  46985. /**
  46986. * This represents a texture coming from an HDR input.
  46987. *
  46988. * The only supported format is currently panorama picture stored in RGBE format.
  46989. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46990. */
  46991. export class HDRCubeTexture extends BaseTexture {
  46992. private static _facesMapping;
  46993. private _generateHarmonics;
  46994. private _noMipmap;
  46995. private _textureMatrix;
  46996. private _size;
  46997. private _onLoad;
  46998. private _onError;
  46999. /**
  47000. * The texture URL.
  47001. */
  47002. url: string;
  47003. /**
  47004. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47005. */
  47006. coordinatesMode: number;
  47007. protected _isBlocking: boolean;
  47008. /**
  47009. * Sets wether or not the texture is blocking during loading.
  47010. */
  47011. /**
  47012. * Gets wether or not the texture is blocking during loading.
  47013. */
  47014. isBlocking: boolean;
  47015. protected _rotationY: number;
  47016. /**
  47017. * Sets texture matrix rotation angle around Y axis in radians.
  47018. */
  47019. /**
  47020. * Gets texture matrix rotation angle around Y axis radians.
  47021. */
  47022. rotationY: number;
  47023. /**
  47024. * Gets or sets the center of the bounding box associated with the cube texture
  47025. * It must define where the camera used to render the texture was set
  47026. */
  47027. boundingBoxPosition: Vector3;
  47028. private _boundingBoxSize;
  47029. /**
  47030. * Gets or sets the size of the bounding box associated with the cube texture
  47031. * When defined, the cubemap will switch to local mode
  47032. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47033. * @example https://www.babylonjs-playground.com/#RNASML
  47034. */
  47035. boundingBoxSize: Vector3;
  47036. /**
  47037. * Instantiates an HDRTexture from the following parameters.
  47038. *
  47039. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47040. * @param scene The scene the texture will be used in
  47041. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47042. * @param noMipmap Forces to not generate the mipmap if true
  47043. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47044. * @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)
  47045. * @param reserved Reserved flag for internal use.
  47046. */
  47047. 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>);
  47048. /**
  47049. * Get the current class name of the texture useful for serialization or dynamic coding.
  47050. * @returns "HDRCubeTexture"
  47051. */
  47052. getClassName(): string;
  47053. /**
  47054. * Occurs when the file is raw .hdr file.
  47055. */
  47056. private loadTexture;
  47057. clone(): HDRCubeTexture;
  47058. delayLoad(): void;
  47059. /**
  47060. * Get the texture reflection matrix used to rotate/transform the reflection.
  47061. * @returns the reflection matrix
  47062. */
  47063. getReflectionTextureMatrix(): Matrix;
  47064. /**
  47065. * Set the texture reflection matrix used to rotate/transform the reflection.
  47066. * @param value Define the reflection matrix to set
  47067. */
  47068. setReflectionTextureMatrix(value: Matrix): void;
  47069. /**
  47070. * Parses a JSON representation of an HDR Texture in order to create the texture
  47071. * @param parsedTexture Define the JSON representation
  47072. * @param scene Define the scene the texture should be created in
  47073. * @param rootUrl Define the root url in case we need to load relative dependencies
  47074. * @returns the newly created texture after parsing
  47075. */
  47076. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47077. serialize(): any;
  47078. }
  47079. }
  47080. declare module BABYLON {
  47081. /**
  47082. * Class used to control physics engine
  47083. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47084. */
  47085. export class PhysicsEngine implements IPhysicsEngine {
  47086. private _physicsPlugin;
  47087. /**
  47088. * Global value used to control the smallest number supported by the simulation
  47089. */
  47090. static Epsilon: number;
  47091. private _impostors;
  47092. private _joints;
  47093. /**
  47094. * Gets the gravity vector used by the simulation
  47095. */
  47096. gravity: Vector3;
  47097. /**
  47098. * Factory used to create the default physics plugin.
  47099. * @returns The default physics plugin
  47100. */
  47101. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47102. /**
  47103. * Creates a new Physics Engine
  47104. * @param gravity defines the gravity vector used by the simulation
  47105. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47106. */
  47107. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47108. /**
  47109. * Sets the gravity vector used by the simulation
  47110. * @param gravity defines the gravity vector to use
  47111. */
  47112. setGravity(gravity: Vector3): void;
  47113. /**
  47114. * Set the time step of the physics engine.
  47115. * Default is 1/60.
  47116. * To slow it down, enter 1/600 for example.
  47117. * To speed it up, 1/30
  47118. * @param newTimeStep defines the new timestep to apply to this world.
  47119. */
  47120. setTimeStep(newTimeStep?: number): void;
  47121. /**
  47122. * Get the time step of the physics engine.
  47123. * @returns the current time step
  47124. */
  47125. getTimeStep(): number;
  47126. /**
  47127. * Release all resources
  47128. */
  47129. dispose(): void;
  47130. /**
  47131. * Gets the name of the current physics plugin
  47132. * @returns the name of the plugin
  47133. */
  47134. getPhysicsPluginName(): string;
  47135. /**
  47136. * Adding a new impostor for the impostor tracking.
  47137. * This will be done by the impostor itself.
  47138. * @param impostor the impostor to add
  47139. */
  47140. addImpostor(impostor: PhysicsImpostor): void;
  47141. /**
  47142. * Remove an impostor from the engine.
  47143. * This impostor and its mesh will not longer be updated by the physics engine.
  47144. * @param impostor the impostor to remove
  47145. */
  47146. removeImpostor(impostor: PhysicsImpostor): void;
  47147. /**
  47148. * Add a joint to the physics engine
  47149. * @param mainImpostor defines the main impostor to which the joint is added.
  47150. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47151. * @param joint defines the joint that will connect both impostors.
  47152. */
  47153. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47154. /**
  47155. * Removes a joint from the simulation
  47156. * @param mainImpostor defines the impostor used with the joint
  47157. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47158. * @param joint defines the joint to remove
  47159. */
  47160. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47161. /**
  47162. * Called by the scene. No need to call it.
  47163. * @param delta defines the timespam between frames
  47164. */ step(delta: number): void;
  47165. /**
  47166. * Gets the current plugin used to run the simulation
  47167. * @returns current plugin
  47168. */
  47169. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47170. /**
  47171. * Gets the list of physic impostors
  47172. * @returns an array of PhysicsImpostor
  47173. */
  47174. getImpostors(): Array<PhysicsImpostor>;
  47175. /**
  47176. * Gets the impostor for a physics enabled object
  47177. * @param object defines the object impersonated by the impostor
  47178. * @returns the PhysicsImpostor or null if not found
  47179. */
  47180. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47181. /**
  47182. * Gets the impostor for a physics body object
  47183. * @param body defines physics body used by the impostor
  47184. * @returns the PhysicsImpostor or null if not found
  47185. */
  47186. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47187. /**
  47188. * Does a raycast in the physics world
  47189. * @param from when should the ray start?
  47190. * @param to when should the ray end?
  47191. * @returns PhysicsRaycastResult
  47192. */
  47193. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47194. }
  47195. }
  47196. declare module BABYLON {
  47197. /** @hidden */
  47198. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47199. private _useDeltaForWorldStep;
  47200. world: any;
  47201. name: string;
  47202. private _physicsMaterials;
  47203. private _fixedTimeStep;
  47204. private _cannonRaycastResult;
  47205. private _raycastResult;
  47206. private _removeAfterStep;
  47207. BJSCANNON: any;
  47208. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47209. setGravity(gravity: Vector3): void;
  47210. setTimeStep(timeStep: number): void;
  47211. getTimeStep(): number;
  47212. executeStep(delta: number): void;
  47213. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47214. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47215. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47216. private _processChildMeshes;
  47217. removePhysicsBody(impostor: PhysicsImpostor): void;
  47218. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47219. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47220. private _addMaterial;
  47221. private _checkWithEpsilon;
  47222. private _createShape;
  47223. private _createHeightmap;
  47224. private _minus90X;
  47225. private _plus90X;
  47226. private _tmpPosition;
  47227. private _tmpDeltaPosition;
  47228. private _tmpUnityRotation;
  47229. private _updatePhysicsBodyTransformation;
  47230. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47231. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47232. isSupported(): boolean;
  47233. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47234. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47235. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47236. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47237. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47238. getBodyMass(impostor: PhysicsImpostor): number;
  47239. getBodyFriction(impostor: PhysicsImpostor): number;
  47240. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47241. getBodyRestitution(impostor: PhysicsImpostor): number;
  47242. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47243. sleepBody(impostor: PhysicsImpostor): void;
  47244. wakeUpBody(impostor: PhysicsImpostor): void;
  47245. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47246. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47247. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47248. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47249. getRadius(impostor: PhysicsImpostor): number;
  47250. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47251. dispose(): void;
  47252. private _extendNamespace;
  47253. /**
  47254. * Does a raycast in the physics world
  47255. * @param from when should the ray start?
  47256. * @param to when should the ray end?
  47257. * @returns PhysicsRaycastResult
  47258. */
  47259. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47260. }
  47261. }
  47262. declare module BABYLON {
  47263. /** @hidden */
  47264. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47265. world: any;
  47266. name: string;
  47267. BJSOIMO: any;
  47268. private _raycastResult;
  47269. constructor(iterations?: number, oimoInjection?: any);
  47270. setGravity(gravity: Vector3): void;
  47271. setTimeStep(timeStep: number): void;
  47272. getTimeStep(): number;
  47273. private _tmpImpostorsArray;
  47274. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47275. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47276. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47277. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47278. private _tmpPositionVector;
  47279. removePhysicsBody(impostor: PhysicsImpostor): void;
  47280. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47281. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47282. isSupported(): boolean;
  47283. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47284. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47285. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47286. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47287. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47288. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47289. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47290. getBodyMass(impostor: PhysicsImpostor): number;
  47291. getBodyFriction(impostor: PhysicsImpostor): number;
  47292. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47293. getBodyRestitution(impostor: PhysicsImpostor): number;
  47294. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47295. sleepBody(impostor: PhysicsImpostor): void;
  47296. wakeUpBody(impostor: PhysicsImpostor): void;
  47297. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47298. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  47299. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47300. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47301. getRadius(impostor: PhysicsImpostor): number;
  47302. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47303. dispose(): void;
  47304. /**
  47305. * Does a raycast in the physics world
  47306. * @param from when should the ray start?
  47307. * @param to when should the ray end?
  47308. * @returns PhysicsRaycastResult
  47309. */
  47310. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47311. }
  47312. }
  47313. declare module BABYLON {
  47314. /**
  47315. * Class containing static functions to help procedurally build meshes
  47316. */
  47317. export class RibbonBuilder {
  47318. /**
  47319. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47320. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  47321. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  47322. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  47323. * * 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
  47324. * * 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
  47325. * * 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
  47326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47327. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47328. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47329. * * 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
  47330. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  47331. * * 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
  47332. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  47333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47334. * @param name defines the name of the mesh
  47335. * @param options defines the options used to create the mesh
  47336. * @param scene defines the hosting scene
  47337. * @returns the ribbon mesh
  47338. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  47339. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47340. */
  47341. static CreateRibbon(name: string, options: {
  47342. pathArray: Vector3[][];
  47343. closeArray?: boolean;
  47344. closePath?: boolean;
  47345. offset?: number;
  47346. updatable?: boolean;
  47347. sideOrientation?: number;
  47348. frontUVs?: Vector4;
  47349. backUVs?: Vector4;
  47350. instance?: Mesh;
  47351. invertUV?: boolean;
  47352. uvs?: Vector2[];
  47353. colors?: Color4[];
  47354. }, scene?: Nullable<Scene>): Mesh;
  47355. }
  47356. }
  47357. declare module BABYLON {
  47358. /**
  47359. * Class containing static functions to help procedurally build meshes
  47360. */
  47361. export class ShapeBuilder {
  47362. /**
  47363. * 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.
  47364. * * 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.
  47365. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47366. * * 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.
  47367. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  47368. * * 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
  47369. * * 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
  47370. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  47371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47372. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47373. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  47374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47375. * @param name defines the name of the mesh
  47376. * @param options defines the options used to create the mesh
  47377. * @param scene defines the hosting scene
  47378. * @returns the extruded shape mesh
  47379. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47380. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47381. */
  47382. static ExtrudeShape(name: string, options: {
  47383. shape: Vector3[];
  47384. path: Vector3[];
  47385. scale?: number;
  47386. rotation?: number;
  47387. cap?: number;
  47388. updatable?: boolean;
  47389. sideOrientation?: number;
  47390. frontUVs?: Vector4;
  47391. backUVs?: Vector4;
  47392. instance?: Mesh;
  47393. invertUV?: boolean;
  47394. }, scene?: Nullable<Scene>): Mesh;
  47395. /**
  47396. * Creates an custom extruded shape mesh.
  47397. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  47398. * * 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.
  47399. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47400. * * 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
  47401. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  47402. * * 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
  47403. * * It must returns a float value that will be the scale value applied to the shape on each path point
  47404. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  47405. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  47406. * * 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
  47407. * * 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
  47408. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  47409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47410. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47411. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47413. * @param name defines the name of the mesh
  47414. * @param options defines the options used to create the mesh
  47415. * @param scene defines the hosting scene
  47416. * @returns the custom extruded shape mesh
  47417. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  47418. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47419. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47420. */
  47421. static ExtrudeShapeCustom(name: string, options: {
  47422. shape: Vector3[];
  47423. path: Vector3[];
  47424. scaleFunction?: any;
  47425. rotationFunction?: any;
  47426. ribbonCloseArray?: boolean;
  47427. ribbonClosePath?: boolean;
  47428. cap?: number;
  47429. updatable?: boolean;
  47430. sideOrientation?: number;
  47431. frontUVs?: Vector4;
  47432. backUVs?: Vector4;
  47433. instance?: Mesh;
  47434. invertUV?: boolean;
  47435. }, scene: Scene): Mesh;
  47436. private static _ExtrudeShapeGeneric;
  47437. }
  47438. }
  47439. declare module BABYLON {
  47440. /**
  47441. * AmmoJS Physics plugin
  47442. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  47443. * @see https://github.com/kripken/ammo.js/
  47444. */
  47445. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  47446. private _useDeltaForWorldStep;
  47447. /**
  47448. * Reference to the Ammo library
  47449. */
  47450. bjsAMMO: any;
  47451. /**
  47452. * Created ammoJS world which physics bodies are added to
  47453. */
  47454. world: any;
  47455. /**
  47456. * Name of the plugin
  47457. */
  47458. name: string;
  47459. private _timeStep;
  47460. private _fixedTimeStep;
  47461. private _maxSteps;
  47462. private _tmpQuaternion;
  47463. private _tmpAmmoTransform;
  47464. private _tmpAmmoQuaternion;
  47465. private _tmpAmmoConcreteContactResultCallback;
  47466. private _collisionConfiguration;
  47467. private _dispatcher;
  47468. private _overlappingPairCache;
  47469. private _solver;
  47470. private _softBodySolver;
  47471. private _tmpAmmoVectorA;
  47472. private _tmpAmmoVectorB;
  47473. private _tmpAmmoVectorC;
  47474. private _tmpAmmoVectorD;
  47475. private _tmpContactCallbackResult;
  47476. private _tmpAmmoVectorRCA;
  47477. private _tmpAmmoVectorRCB;
  47478. private _raycastResult;
  47479. private static readonly DISABLE_COLLISION_FLAG;
  47480. private static readonly KINEMATIC_FLAG;
  47481. private static readonly DISABLE_DEACTIVATION_FLAG;
  47482. /**
  47483. * Initializes the ammoJS plugin
  47484. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  47485. * @param ammoInjection can be used to inject your own ammo reference
  47486. */
  47487. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  47488. /**
  47489. * Sets the gravity of the physics world (m/(s^2))
  47490. * @param gravity Gravity to set
  47491. */
  47492. setGravity(gravity: Vector3): void;
  47493. /**
  47494. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  47495. * @param timeStep timestep to use in seconds
  47496. */
  47497. setTimeStep(timeStep: number): void;
  47498. /**
  47499. * 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)
  47500. * @param fixedTimeStep fixedTimeStep to use in seconds
  47501. */
  47502. setFixedTimeStep(fixedTimeStep: number): void;
  47503. /**
  47504. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  47505. * @param maxSteps the maximum number of steps by the physics engine per frame
  47506. */
  47507. setMaxSteps(maxSteps: number): void;
  47508. /**
  47509. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  47510. * @returns the current timestep in seconds
  47511. */
  47512. getTimeStep(): number;
  47513. private _isImpostorInContact;
  47514. private _isImpostorPairInContact;
  47515. private _stepSimulation;
  47516. /**
  47517. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  47518. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  47519. * After the step the babylon meshes are set to the position of the physics imposters
  47520. * @param delta amount of time to step forward
  47521. * @param impostors array of imposters to update before/after the step
  47522. */
  47523. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47524. /**
  47525. * Update babylon mesh to match physics world object
  47526. * @param impostor imposter to match
  47527. */
  47528. private _afterSoftStep;
  47529. /**
  47530. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47531. * @param impostor imposter to match
  47532. */
  47533. private _ropeStep;
  47534. /**
  47535. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47536. * @param impostor imposter to match
  47537. */
  47538. private _softbodyOrClothStep;
  47539. private _tmpVector;
  47540. private _tmpMatrix;
  47541. /**
  47542. * Applies an impulse on the imposter
  47543. * @param impostor imposter to apply impulse to
  47544. * @param force amount of force to be applied to the imposter
  47545. * @param contactPoint the location to apply the impulse on the imposter
  47546. */
  47547. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47548. /**
  47549. * Applies a force on the imposter
  47550. * @param impostor imposter to apply force
  47551. * @param force amount of force to be applied to the imposter
  47552. * @param contactPoint the location to apply the force on the imposter
  47553. */
  47554. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47555. /**
  47556. * Creates a physics body using the plugin
  47557. * @param impostor the imposter to create the physics body on
  47558. */
  47559. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47560. /**
  47561. * Removes the physics body from the imposter and disposes of the body's memory
  47562. * @param impostor imposter to remove the physics body from
  47563. */
  47564. removePhysicsBody(impostor: PhysicsImpostor): void;
  47565. /**
  47566. * Generates a joint
  47567. * @param impostorJoint the imposter joint to create the joint with
  47568. */
  47569. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47570. /**
  47571. * Removes a joint
  47572. * @param impostorJoint the imposter joint to remove the joint from
  47573. */
  47574. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47575. private _addMeshVerts;
  47576. /**
  47577. * Initialise the soft body vertices to match its object's (mesh) vertices
  47578. * Softbody vertices (nodes) are in world space and to match this
  47579. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  47580. * @param impostor to create the softbody for
  47581. */
  47582. private _softVertexData;
  47583. /**
  47584. * Create an impostor's soft body
  47585. * @param impostor to create the softbody for
  47586. */
  47587. private _createSoftbody;
  47588. /**
  47589. * Create cloth for an impostor
  47590. * @param impostor to create the softbody for
  47591. */
  47592. private _createCloth;
  47593. /**
  47594. * Create rope for an impostor
  47595. * @param impostor to create the softbody for
  47596. */
  47597. private _createRope;
  47598. private _addHullVerts;
  47599. private _createShape;
  47600. /**
  47601. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  47602. * @param impostor imposter containing the physics body and babylon object
  47603. */
  47604. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47605. /**
  47606. * Sets the babylon object's position/rotation from the physics body's position/rotation
  47607. * @param impostor imposter containing the physics body and babylon object
  47608. * @param newPosition new position
  47609. * @param newRotation new rotation
  47610. */
  47611. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47612. /**
  47613. * If this plugin is supported
  47614. * @returns true if its supported
  47615. */
  47616. isSupported(): boolean;
  47617. /**
  47618. * Sets the linear velocity of the physics body
  47619. * @param impostor imposter to set the velocity on
  47620. * @param velocity velocity to set
  47621. */
  47622. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47623. /**
  47624. * Sets the angular velocity of the physics body
  47625. * @param impostor imposter to set the velocity on
  47626. * @param velocity velocity to set
  47627. */
  47628. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47629. /**
  47630. * gets the linear velocity
  47631. * @param impostor imposter to get linear velocity from
  47632. * @returns linear velocity
  47633. */
  47634. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47635. /**
  47636. * gets the angular velocity
  47637. * @param impostor imposter to get angular velocity from
  47638. * @returns angular velocity
  47639. */
  47640. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47641. /**
  47642. * Sets the mass of physics body
  47643. * @param impostor imposter to set the mass on
  47644. * @param mass mass to set
  47645. */
  47646. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47647. /**
  47648. * Gets the mass of the physics body
  47649. * @param impostor imposter to get the mass from
  47650. * @returns mass
  47651. */
  47652. getBodyMass(impostor: PhysicsImpostor): number;
  47653. /**
  47654. * Gets friction of the impostor
  47655. * @param impostor impostor to get friction from
  47656. * @returns friction value
  47657. */
  47658. getBodyFriction(impostor: PhysicsImpostor): number;
  47659. /**
  47660. * Sets friction of the impostor
  47661. * @param impostor impostor to set friction on
  47662. * @param friction friction value
  47663. */
  47664. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47665. /**
  47666. * Gets restitution of the impostor
  47667. * @param impostor impostor to get restitution from
  47668. * @returns restitution value
  47669. */
  47670. getBodyRestitution(impostor: PhysicsImpostor): number;
  47671. /**
  47672. * Sets resitution of the impostor
  47673. * @param impostor impostor to set resitution on
  47674. * @param restitution resitution value
  47675. */
  47676. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47677. /**
  47678. * Gets pressure inside the impostor
  47679. * @param impostor impostor to get pressure from
  47680. * @returns pressure value
  47681. */
  47682. getBodyPressure(impostor: PhysicsImpostor): number;
  47683. /**
  47684. * Sets pressure inside a soft body impostor
  47685. * Cloth and rope must remain 0 pressure
  47686. * @param impostor impostor to set pressure on
  47687. * @param pressure pressure value
  47688. */
  47689. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  47690. /**
  47691. * Gets stiffness of the impostor
  47692. * @param impostor impostor to get stiffness from
  47693. * @returns pressure value
  47694. */
  47695. getBodyStiffness(impostor: PhysicsImpostor): number;
  47696. /**
  47697. * Sets stiffness of the impostor
  47698. * @param impostor impostor to set stiffness on
  47699. * @param stiffness stiffness value from 0 to 1
  47700. */
  47701. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  47702. /**
  47703. * Gets velocityIterations of the impostor
  47704. * @param impostor impostor to get velocity iterations from
  47705. * @returns velocityIterations value
  47706. */
  47707. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  47708. /**
  47709. * Sets velocityIterations of the impostor
  47710. * @param impostor impostor to set velocity iterations on
  47711. * @param velocityIterations velocityIterations value
  47712. */
  47713. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  47714. /**
  47715. * Gets positionIterations of the impostor
  47716. * @param impostor impostor to get position iterations from
  47717. * @returns positionIterations value
  47718. */
  47719. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  47720. /**
  47721. * Sets positionIterations of the impostor
  47722. * @param impostor impostor to set position on
  47723. * @param positionIterations positionIterations value
  47724. */
  47725. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  47726. /**
  47727. * Append an anchor to a cloth object
  47728. * @param impostor is the cloth impostor to add anchor to
  47729. * @param otherImpostor is the rigid impostor to anchor to
  47730. * @param width ratio across width from 0 to 1
  47731. * @param height ratio up height from 0 to 1
  47732. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  47733. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  47734. */
  47735. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  47736. /**
  47737. * Append an hook to a rope object
  47738. * @param impostor is the rope impostor to add hook to
  47739. * @param otherImpostor is the rigid impostor to hook to
  47740. * @param length ratio along the rope from 0 to 1
  47741. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  47742. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  47743. */
  47744. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  47745. /**
  47746. * Sleeps the physics body and stops it from being active
  47747. * @param impostor impostor to sleep
  47748. */
  47749. sleepBody(impostor: PhysicsImpostor): void;
  47750. /**
  47751. * Activates the physics body
  47752. * @param impostor impostor to activate
  47753. */
  47754. wakeUpBody(impostor: PhysicsImpostor): void;
  47755. /**
  47756. * Updates the distance parameters of the joint
  47757. * @param joint joint to update
  47758. * @param maxDistance maximum distance of the joint
  47759. * @param minDistance minimum distance of the joint
  47760. */
  47761. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47762. /**
  47763. * Sets a motor on the joint
  47764. * @param joint joint to set motor on
  47765. * @param speed speed of the motor
  47766. * @param maxForce maximum force of the motor
  47767. * @param motorIndex index of the motor
  47768. */
  47769. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47770. /**
  47771. * Sets the motors limit
  47772. * @param joint joint to set limit on
  47773. * @param upperLimit upper limit
  47774. * @param lowerLimit lower limit
  47775. */
  47776. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47777. /**
  47778. * Syncs the position and rotation of a mesh with the impostor
  47779. * @param mesh mesh to sync
  47780. * @param impostor impostor to update the mesh with
  47781. */
  47782. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47783. /**
  47784. * Gets the radius of the impostor
  47785. * @param impostor impostor to get radius from
  47786. * @returns the radius
  47787. */
  47788. getRadius(impostor: PhysicsImpostor): number;
  47789. /**
  47790. * Gets the box size of the impostor
  47791. * @param impostor impostor to get box size from
  47792. * @param result the resulting box size
  47793. */
  47794. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47795. /**
  47796. * Disposes of the impostor
  47797. */
  47798. dispose(): void;
  47799. /**
  47800. * Does a raycast in the physics world
  47801. * @param from when should the ray start?
  47802. * @param to when should the ray end?
  47803. * @returns PhysicsRaycastResult
  47804. */
  47805. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47806. }
  47807. }
  47808. declare module BABYLON {
  47809. interface AbstractScene {
  47810. /**
  47811. * The list of reflection probes added to the scene
  47812. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47813. */
  47814. reflectionProbes: Array<ReflectionProbe>;
  47815. /**
  47816. * Removes the given reflection probe from this scene.
  47817. * @param toRemove The reflection probe to remove
  47818. * @returns The index of the removed reflection probe
  47819. */
  47820. removeReflectionProbe(toRemove: ReflectionProbe): number;
  47821. /**
  47822. * Adds the given reflection probe to this scene.
  47823. * @param newReflectionProbe The reflection probe to add
  47824. */
  47825. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  47826. }
  47827. /**
  47828. * Class used to generate realtime reflection / refraction cube textures
  47829. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47830. */
  47831. export class ReflectionProbe {
  47832. /** defines the name of the probe */
  47833. name: string;
  47834. private _scene;
  47835. private _renderTargetTexture;
  47836. private _projectionMatrix;
  47837. private _viewMatrix;
  47838. private _target;
  47839. private _add;
  47840. private _attachedMesh;
  47841. private _invertYAxis;
  47842. /** Gets or sets probe position (center of the cube map) */
  47843. position: Vector3;
  47844. /**
  47845. * Creates a new reflection probe
  47846. * @param name defines the name of the probe
  47847. * @param size defines the texture resolution (for each face)
  47848. * @param scene defines the hosting scene
  47849. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  47850. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  47851. */
  47852. constructor(
  47853. /** defines the name of the probe */
  47854. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  47855. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  47856. samples: number;
  47857. /** Gets or sets the refresh rate to use (on every frame by default) */
  47858. refreshRate: number;
  47859. /**
  47860. * Gets the hosting scene
  47861. * @returns a Scene
  47862. */
  47863. getScene(): Scene;
  47864. /** Gets the internal CubeTexture used to render to */
  47865. readonly cubeTexture: RenderTargetTexture;
  47866. /** Gets the list of meshes to render */
  47867. readonly renderList: Nullable<AbstractMesh[]>;
  47868. /**
  47869. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  47870. * @param mesh defines the mesh to attach to
  47871. */
  47872. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47873. /**
  47874. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  47875. * @param renderingGroupId The rendering group id corresponding to its index
  47876. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47877. */
  47878. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47879. /**
  47880. * Clean all associated resources
  47881. */
  47882. dispose(): void;
  47883. /**
  47884. * Converts the reflection probe information to a readable string for debug purpose.
  47885. * @param fullDetails Supports for multiple levels of logging within scene loading
  47886. * @returns the human readable reflection probe info
  47887. */
  47888. toString(fullDetails?: boolean): string;
  47889. /**
  47890. * Get the class name of the relfection probe.
  47891. * @returns "ReflectionProbe"
  47892. */
  47893. getClassName(): string;
  47894. /**
  47895. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  47896. * @returns The JSON representation of the texture
  47897. */
  47898. serialize(): any;
  47899. /**
  47900. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  47901. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  47902. * @param scene Define the scene the parsed reflection probe should be instantiated in
  47903. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47904. * @returns The parsed reflection probe if successful
  47905. */
  47906. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  47907. }
  47908. }
  47909. declare module BABYLON {
  47910. /** @hidden */
  47911. export var _BabylonLoaderRegistered: boolean;
  47912. }
  47913. declare module BABYLON {
  47914. /**
  47915. * The Physically based simple base material of BJS.
  47916. *
  47917. * This enables better naming and convention enforcements on top of the pbrMaterial.
  47918. * It is used as the base class for both the specGloss and metalRough conventions.
  47919. */
  47920. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  47921. /**
  47922. * Number of Simultaneous lights allowed on the material.
  47923. */
  47924. maxSimultaneousLights: number;
  47925. /**
  47926. * If sets to true, disables all the lights affecting the material.
  47927. */
  47928. disableLighting: boolean;
  47929. /**
  47930. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  47931. */
  47932. environmentTexture: BaseTexture;
  47933. /**
  47934. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47935. */
  47936. invertNormalMapX: boolean;
  47937. /**
  47938. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47939. */
  47940. invertNormalMapY: boolean;
  47941. /**
  47942. * Normal map used in the model.
  47943. */
  47944. normalTexture: BaseTexture;
  47945. /**
  47946. * Emissivie color used to self-illuminate the model.
  47947. */
  47948. emissiveColor: Color3;
  47949. /**
  47950. * Emissivie texture used to self-illuminate the model.
  47951. */
  47952. emissiveTexture: BaseTexture;
  47953. /**
  47954. * Occlusion Channel Strenght.
  47955. */
  47956. occlusionStrength: number;
  47957. /**
  47958. * Occlusion Texture of the material (adding extra occlusion effects).
  47959. */
  47960. occlusionTexture: BaseTexture;
  47961. /**
  47962. * Defines the alpha limits in alpha test mode.
  47963. */
  47964. alphaCutOff: number;
  47965. /**
  47966. * Gets the current double sided mode.
  47967. */
  47968. /**
  47969. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47970. */
  47971. doubleSided: boolean;
  47972. /**
  47973. * Stores the pre-calculated light information of a mesh in a texture.
  47974. */
  47975. lightmapTexture: BaseTexture;
  47976. /**
  47977. * If true, the light map contains occlusion information instead of lighting info.
  47978. */
  47979. useLightmapAsShadowmap: boolean;
  47980. /**
  47981. * Instantiates a new PBRMaterial instance.
  47982. *
  47983. * @param name The material name
  47984. * @param scene The scene the material will be use in.
  47985. */
  47986. constructor(name: string, scene: Scene);
  47987. getClassName(): string;
  47988. }
  47989. }
  47990. declare module BABYLON {
  47991. /**
  47992. * The PBR material of BJS following the metal roughness convention.
  47993. *
  47994. * This fits to the PBR convention in the GLTF definition:
  47995. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  47996. */
  47997. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  47998. /**
  47999. * The base color has two different interpretations depending on the value of metalness.
  48000. * When the material is a metal, the base color is the specific measured reflectance value
  48001. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48002. * of the material.
  48003. */
  48004. baseColor: Color3;
  48005. /**
  48006. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48007. * well as opacity information in the alpha channel.
  48008. */
  48009. baseTexture: BaseTexture;
  48010. /**
  48011. * Specifies the metallic scalar value of the material.
  48012. * Can also be used to scale the metalness values of the metallic texture.
  48013. */
  48014. metallic: number;
  48015. /**
  48016. * Specifies the roughness scalar value of the material.
  48017. * Can also be used to scale the roughness values of the metallic texture.
  48018. */
  48019. roughness: number;
  48020. /**
  48021. * Texture containing both the metallic value in the B channel and the
  48022. * roughness value in the G channel to keep better precision.
  48023. */
  48024. metallicRoughnessTexture: BaseTexture;
  48025. /**
  48026. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48027. *
  48028. * @param name The material name
  48029. * @param scene The scene the material will be use in.
  48030. */
  48031. constructor(name: string, scene: Scene);
  48032. /**
  48033. * Return the currrent class name of the material.
  48034. */
  48035. getClassName(): string;
  48036. /**
  48037. * Makes a duplicate of the current material.
  48038. * @param name - name to use for the new material.
  48039. */
  48040. clone(name: string): PBRMetallicRoughnessMaterial;
  48041. /**
  48042. * Serialize the material to a parsable JSON object.
  48043. */
  48044. serialize(): any;
  48045. /**
  48046. * Parses a JSON object correponding to the serialize function.
  48047. */
  48048. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48049. }
  48050. }
  48051. declare module BABYLON {
  48052. /**
  48053. * The PBR material of BJS following the specular glossiness convention.
  48054. *
  48055. * This fits to the PBR convention in the GLTF definition:
  48056. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48057. */
  48058. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48059. /**
  48060. * Specifies the diffuse color of the material.
  48061. */
  48062. diffuseColor: Color3;
  48063. /**
  48064. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48065. * channel.
  48066. */
  48067. diffuseTexture: BaseTexture;
  48068. /**
  48069. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48070. */
  48071. specularColor: Color3;
  48072. /**
  48073. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48074. */
  48075. glossiness: number;
  48076. /**
  48077. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48078. */
  48079. specularGlossinessTexture: BaseTexture;
  48080. /**
  48081. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48082. *
  48083. * @param name The material name
  48084. * @param scene The scene the material will be use in.
  48085. */
  48086. constructor(name: string, scene: Scene);
  48087. /**
  48088. * Return the currrent class name of the material.
  48089. */
  48090. getClassName(): string;
  48091. /**
  48092. * Makes a duplicate of the current material.
  48093. * @param name - name to use for the new material.
  48094. */
  48095. clone(name: string): PBRSpecularGlossinessMaterial;
  48096. /**
  48097. * Serialize the material to a parsable JSON object.
  48098. */
  48099. serialize(): any;
  48100. /**
  48101. * Parses a JSON object correponding to the serialize function.
  48102. */
  48103. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48104. }
  48105. }
  48106. declare module BABYLON {
  48107. /**
  48108. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48109. * It can help converting any input color in a desired output one. This can then be used to create effects
  48110. * from sepia, black and white to sixties or futuristic rendering...
  48111. *
  48112. * The only supported format is currently 3dl.
  48113. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48114. */
  48115. export class ColorGradingTexture extends BaseTexture {
  48116. /**
  48117. * The current texture matrix. (will always be identity in color grading texture)
  48118. */
  48119. private _textureMatrix;
  48120. /**
  48121. * The texture URL.
  48122. */
  48123. url: string;
  48124. /**
  48125. * Empty line regex stored for GC.
  48126. */
  48127. private static _noneEmptyLineRegex;
  48128. private _engine;
  48129. /**
  48130. * Instantiates a ColorGradingTexture from the following parameters.
  48131. *
  48132. * @param url The location of the color gradind data (currently only supporting 3dl)
  48133. * @param scene The scene the texture will be used in
  48134. */
  48135. constructor(url: string, scene: Scene);
  48136. /**
  48137. * Returns the texture matrix used in most of the material.
  48138. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48139. */
  48140. getTextureMatrix(): Matrix;
  48141. /**
  48142. * Occurs when the file being loaded is a .3dl LUT file.
  48143. */
  48144. private load3dlTexture;
  48145. /**
  48146. * Starts the loading process of the texture.
  48147. */
  48148. private loadTexture;
  48149. /**
  48150. * Clones the color gradind texture.
  48151. */
  48152. clone(): ColorGradingTexture;
  48153. /**
  48154. * Called during delayed load for textures.
  48155. */
  48156. delayLoad(): void;
  48157. /**
  48158. * Parses a color grading texture serialized by Babylon.
  48159. * @param parsedTexture The texture information being parsedTexture
  48160. * @param scene The scene to load the texture in
  48161. * @param rootUrl The root url of the data assets to load
  48162. * @return A color gradind texture
  48163. */
  48164. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48165. /**
  48166. * Serializes the LUT texture to json format.
  48167. */
  48168. serialize(): any;
  48169. }
  48170. }
  48171. declare module BABYLON {
  48172. /**
  48173. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  48174. */
  48175. export class EquiRectangularCubeTexture extends BaseTexture {
  48176. /** The six faces of the cube. */
  48177. private static _FacesMapping;
  48178. private _noMipmap;
  48179. private _onLoad;
  48180. private _onError;
  48181. /** The size of the cubemap. */
  48182. private _size;
  48183. /** The buffer of the image. */
  48184. private _buffer;
  48185. /** The width of the input image. */
  48186. private _width;
  48187. /** The height of the input image. */
  48188. private _height;
  48189. /** The URL to the image. */
  48190. url: string;
  48191. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  48192. coordinatesMode: number;
  48193. /**
  48194. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  48195. * @param url The location of the image
  48196. * @param scene The scene the texture will be used in
  48197. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48198. * @param noMipmap Forces to not generate the mipmap if true
  48199. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  48200. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  48201. * @param onLoad — defines a callback called when texture is loaded
  48202. * @param onError — defines a callback called if there is an error
  48203. */
  48204. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  48205. /**
  48206. * Load the image data, by putting the image on a canvas and extracting its buffer.
  48207. */
  48208. private loadImage;
  48209. /**
  48210. * Convert the image buffer into a cubemap and create a CubeTexture.
  48211. */
  48212. private loadTexture;
  48213. /**
  48214. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  48215. * @param buffer The ArrayBuffer that should be converted.
  48216. * @returns The buffer as Float32Array.
  48217. */
  48218. private getFloat32ArrayFromArrayBuffer;
  48219. /**
  48220. * Get the current class name of the texture useful for serialization or dynamic coding.
  48221. * @returns "EquiRectangularCubeTexture"
  48222. */
  48223. getClassName(): string;
  48224. /**
  48225. * Create a clone of the current EquiRectangularCubeTexture and return it.
  48226. * @returns A clone of the current EquiRectangularCubeTexture.
  48227. */
  48228. clone(): EquiRectangularCubeTexture;
  48229. }
  48230. }
  48231. declare module BABYLON {
  48232. /**
  48233. * Based on jsTGALoader - Javascript loader for TGA file
  48234. * By Vincent Thibault
  48235. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48236. */
  48237. export class TGATools {
  48238. private static _TYPE_INDEXED;
  48239. private static _TYPE_RGB;
  48240. private static _TYPE_GREY;
  48241. private static _TYPE_RLE_INDEXED;
  48242. private static _TYPE_RLE_RGB;
  48243. private static _TYPE_RLE_GREY;
  48244. private static _ORIGIN_MASK;
  48245. private static _ORIGIN_SHIFT;
  48246. private static _ORIGIN_BL;
  48247. private static _ORIGIN_BR;
  48248. private static _ORIGIN_UL;
  48249. private static _ORIGIN_UR;
  48250. /**
  48251. * Gets the header of a TGA file
  48252. * @param data defines the TGA data
  48253. * @returns the header
  48254. */
  48255. static GetTGAHeader(data: Uint8Array): any;
  48256. /**
  48257. * Uploads TGA content to a Babylon Texture
  48258. * @hidden
  48259. */
  48260. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48261. /** @hidden */ private 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;
  48262. /** @hidden */ private 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;
  48263. /** @hidden */ private 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;
  48264. /** @hidden */ private 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;
  48265. /** @hidden */ private 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;
  48266. /** @hidden */ private 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;
  48267. }
  48268. }
  48269. declare module BABYLON {
  48270. /**
  48271. * Implementation of the TGA Texture Loader.
  48272. * @hidden
  48273. */
  48274. export class _TGATextureLoader implements IInternalTextureLoader {
  48275. /**
  48276. * Defines wether the loader supports cascade loading the different faces.
  48277. */
  48278. readonly supportCascades: boolean;
  48279. /**
  48280. * This returns if the loader support the current file information.
  48281. * @param extension defines the file extension of the file being loaded
  48282. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48283. * @param fallback defines the fallback internal texture if any
  48284. * @param isBase64 defines whether the texture is encoded as a base64
  48285. * @param isBuffer defines whether the texture data are stored as a buffer
  48286. * @returns true if the loader can load the specified file
  48287. */
  48288. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48289. /**
  48290. * Transform the url before loading if required.
  48291. * @param rootUrl the url of the texture
  48292. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48293. * @returns the transformed texture
  48294. */
  48295. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48296. /**
  48297. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48298. * @param rootUrl the url of the texture
  48299. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48300. * @returns the fallback texture
  48301. */
  48302. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48303. /**
  48304. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48305. * @param data contains the texture data
  48306. * @param texture defines the BabylonJS internal texture
  48307. * @param createPolynomials will be true if polynomials have been requested
  48308. * @param onLoad defines the callback to trigger once the texture is ready
  48309. * @param onError defines the callback to trigger in case of error
  48310. */
  48311. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48312. /**
  48313. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48314. * @param data contains the texture data
  48315. * @param texture defines the BabylonJS internal texture
  48316. * @param callback defines the method to call once ready to upload
  48317. */
  48318. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48319. }
  48320. }
  48321. declare module BABYLON {
  48322. /**
  48323. * 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.
  48324. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48325. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48326. */
  48327. export class CustomProceduralTexture extends ProceduralTexture {
  48328. private _animate;
  48329. private _time;
  48330. private _config;
  48331. private _texturePath;
  48332. /**
  48333. * Instantiates a new Custom Procedural Texture.
  48334. * 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.
  48335. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48336. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48337. * @param name Define the name of the texture
  48338. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48339. * @param size Define the size of the texture to create
  48340. * @param scene Define the scene the texture belongs to
  48341. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48342. * @param generateMipMaps Define if the texture should creates mip maps or not
  48343. */
  48344. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48345. private _loadJson;
  48346. /**
  48347. * Is the texture ready to be used ? (rendered at least once)
  48348. * @returns true if ready, otherwise, false.
  48349. */
  48350. isReady(): boolean;
  48351. /**
  48352. * Render the texture to its associated render target.
  48353. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48354. */
  48355. render(useCameraPostProcess?: boolean): void;
  48356. /**
  48357. * Update the list of dependant textures samplers in the shader.
  48358. */
  48359. updateTextures(): void;
  48360. /**
  48361. * Update the uniform values of the procedural texture in the shader.
  48362. */
  48363. updateShaderUniforms(): void;
  48364. /**
  48365. * Define if the texture animates or not.
  48366. */
  48367. animate: boolean;
  48368. }
  48369. }
  48370. declare module BABYLON {
  48371. /** @hidden */
  48372. export var noisePixelShader: {
  48373. name: string;
  48374. shader: string;
  48375. };
  48376. }
  48377. declare module BABYLON {
  48378. /**
  48379. * Class used to generate noise procedural textures
  48380. */
  48381. export class NoiseProceduralTexture extends ProceduralTexture {
  48382. private _time;
  48383. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48384. brightness: number;
  48385. /** Defines the number of octaves to process */
  48386. octaves: number;
  48387. /** Defines the level of persistence (0.8 by default) */
  48388. persistence: number;
  48389. /** Gets or sets animation speed factor (default is 1) */
  48390. animationSpeedFactor: number;
  48391. /**
  48392. * Creates a new NoiseProceduralTexture
  48393. * @param name defines the name fo the texture
  48394. * @param size defines the size of the texture (default is 256)
  48395. * @param scene defines the hosting scene
  48396. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48397. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48398. */
  48399. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48400. private _updateShaderUniforms;
  48401. protected _getDefines(): string;
  48402. /** Generate the current state of the procedural texture */
  48403. render(useCameraPostProcess?: boolean): void;
  48404. /**
  48405. * Serializes this noise procedural texture
  48406. * @returns a serialized noise procedural texture object
  48407. */
  48408. serialize(): any;
  48409. /**
  48410. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48411. * @param parsedTexture defines parsed texture data
  48412. * @param scene defines the current scene
  48413. * @param rootUrl defines the root URL containing noise procedural texture information
  48414. * @returns a parsed NoiseProceduralTexture
  48415. */
  48416. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48417. }
  48418. }
  48419. declare module BABYLON {
  48420. /**
  48421. * Raw cube texture where the raw buffers are passed in
  48422. */
  48423. export class RawCubeTexture extends CubeTexture {
  48424. /**
  48425. * Creates a cube texture where the raw buffers are passed in.
  48426. * @param scene defines the scene the texture is attached to
  48427. * @param data defines the array of data to use to create each face
  48428. * @param size defines the size of the textures
  48429. * @param format defines the format of the data
  48430. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48431. * @param generateMipMaps defines if the engine should generate the mip levels
  48432. * @param invertY defines if data must be stored with Y axis inverted
  48433. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48434. * @param compression defines the compression used (null by default)
  48435. */
  48436. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48437. /**
  48438. * Updates the raw cube texture.
  48439. * @param data defines the data to store
  48440. * @param format defines the data format
  48441. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48442. * @param invertY defines if data must be stored with Y axis inverted
  48443. * @param compression defines the compression used (null by default)
  48444. * @param level defines which level of the texture to update
  48445. */
  48446. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48447. /**
  48448. * Updates a raw cube texture with RGBD encoded data.
  48449. * @param data defines the array of data [mipmap][face] to use to create each face
  48450. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48451. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48452. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48453. * @returns a promsie that resolves when the operation is complete
  48454. */
  48455. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48456. /**
  48457. * Clones the raw cube texture.
  48458. * @return a new cube texture
  48459. */
  48460. clone(): CubeTexture;
  48461. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48462. }
  48463. }
  48464. declare module BABYLON {
  48465. /**
  48466. * Class used to store 3D textures containing user data
  48467. */
  48468. export class RawTexture3D extends Texture {
  48469. /** Gets or sets the texture format to use */
  48470. format: number;
  48471. private _engine;
  48472. /**
  48473. * Create a new RawTexture3D
  48474. * @param data defines the data of the texture
  48475. * @param width defines the width of the texture
  48476. * @param height defines the height of the texture
  48477. * @param depth defines the depth of the texture
  48478. * @param format defines the texture format to use
  48479. * @param scene defines the hosting scene
  48480. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48481. * @param invertY defines if texture must be stored with Y axis inverted
  48482. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48483. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48484. */
  48485. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48486. /** Gets or sets the texture format to use */
  48487. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48488. /**
  48489. * Update the texture with new data
  48490. * @param data defines the data to store in the texture
  48491. */
  48492. update(data: ArrayBufferView): void;
  48493. }
  48494. }
  48495. declare module BABYLON {
  48496. /**
  48497. * Creates a refraction texture used by refraction channel of the standard material.
  48498. * It is like a mirror but to see through a material.
  48499. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48500. */
  48501. export class RefractionTexture extends RenderTargetTexture {
  48502. /**
  48503. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48504. * 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.
  48505. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48506. */
  48507. refractionPlane: Plane;
  48508. /**
  48509. * Define how deep under the surface we should see.
  48510. */
  48511. depth: number;
  48512. /**
  48513. * Creates a refraction texture used by refraction channel of the standard material.
  48514. * It is like a mirror but to see through a material.
  48515. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48516. * @param name Define the texture name
  48517. * @param size Define the size of the underlying texture
  48518. * @param scene Define the scene the refraction belongs to
  48519. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48520. */
  48521. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48522. /**
  48523. * Clone the refraction texture.
  48524. * @returns the cloned texture
  48525. */
  48526. clone(): RefractionTexture;
  48527. /**
  48528. * Serialize the texture to a JSON representation you could use in Parse later on
  48529. * @returns the serialized JSON representation
  48530. */
  48531. serialize(): any;
  48532. }
  48533. }
  48534. declare module BABYLON {
  48535. /**
  48536. * Configuration for Draco compression
  48537. */
  48538. export interface IDracoCompressionConfiguration {
  48539. /**
  48540. * Configuration for the decoder.
  48541. */
  48542. decoder?: {
  48543. /**
  48544. * The url to the WebAssembly module.
  48545. */
  48546. wasmUrl?: string;
  48547. /**
  48548. * The url to the WebAssembly binary.
  48549. */
  48550. wasmBinaryUrl?: string;
  48551. /**
  48552. * The url to the fallback JavaScript module.
  48553. */
  48554. fallbackUrl?: string;
  48555. };
  48556. }
  48557. /**
  48558. * Draco compression (https://google.github.io/draco/)
  48559. *
  48560. * This class wraps the Draco module.
  48561. *
  48562. * **Encoder**
  48563. *
  48564. * The encoder is not currently implemented.
  48565. *
  48566. * **Decoder**
  48567. *
  48568. * 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.
  48569. *
  48570. * To update the configuration, use the following code:
  48571. * ```javascript
  48572. * DracoCompression.Configuration = {
  48573. * decoder: {
  48574. * wasmUrl: "<url to the WebAssembly library>",
  48575. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48576. * fallbackUrl: "<url to the fallback JavaScript library>",
  48577. * }
  48578. * };
  48579. * ```
  48580. *
  48581. * 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.
  48582. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48583. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48584. *
  48585. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48586. * ```javascript
  48587. * var dracoCompression = new DracoCompression();
  48588. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48589. * [VertexBuffer.PositionKind]: 0
  48590. * });
  48591. * ```
  48592. *
  48593. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48594. */
  48595. export class DracoCompression implements IDisposable {
  48596. private static _DecoderModulePromise;
  48597. /**
  48598. * The configuration. Defaults to the following urls:
  48599. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48600. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48601. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48602. */
  48603. static Configuration: IDracoCompressionConfiguration;
  48604. /**
  48605. * Returns true if the decoder is available.
  48606. */
  48607. static readonly DecoderAvailable: boolean;
  48608. /**
  48609. * Constructor
  48610. */
  48611. constructor();
  48612. /**
  48613. * Stop all async operations and release resources.
  48614. */
  48615. dispose(): void;
  48616. /**
  48617. * Decode Draco compressed mesh data to vertex data.
  48618. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48619. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48620. * @returns A promise that resolves with the decoded vertex data
  48621. */
  48622. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48623. [kind: string]: number;
  48624. }): Promise<VertexData>;
  48625. private static _GetDecoderModule;
  48626. private static _LoadScriptAsync;
  48627. private static _LoadFileAsync;
  48628. }
  48629. }
  48630. declare module BABYLON {
  48631. /**
  48632. * Class for building Constructive Solid Geometry
  48633. */
  48634. export class CSG {
  48635. private polygons;
  48636. /**
  48637. * The world matrix
  48638. */
  48639. matrix: Matrix;
  48640. /**
  48641. * Stores the position
  48642. */
  48643. position: Vector3;
  48644. /**
  48645. * Stores the rotation
  48646. */
  48647. rotation: Vector3;
  48648. /**
  48649. * Stores the rotation quaternion
  48650. */
  48651. rotationQuaternion: Nullable<Quaternion>;
  48652. /**
  48653. * Stores the scaling vector
  48654. */
  48655. scaling: Vector3;
  48656. /**
  48657. * Convert the Mesh to CSG
  48658. * @param mesh The Mesh to convert to CSG
  48659. * @returns A new CSG from the Mesh
  48660. */
  48661. static FromMesh(mesh: Mesh): CSG;
  48662. /**
  48663. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  48664. * @param polygons Polygons used to construct a CSG solid
  48665. */
  48666. private static FromPolygons;
  48667. /**
  48668. * Clones, or makes a deep copy, of the CSG
  48669. * @returns A new CSG
  48670. */
  48671. clone(): CSG;
  48672. /**
  48673. * Unions this CSG with another CSG
  48674. * @param csg The CSG to union against this CSG
  48675. * @returns The unioned CSG
  48676. */
  48677. union(csg: CSG): CSG;
  48678. /**
  48679. * Unions this CSG with another CSG in place
  48680. * @param csg The CSG to union against this CSG
  48681. */
  48682. unionInPlace(csg: CSG): void;
  48683. /**
  48684. * Subtracts this CSG with another CSG
  48685. * @param csg The CSG to subtract against this CSG
  48686. * @returns A new CSG
  48687. */
  48688. subtract(csg: CSG): CSG;
  48689. /**
  48690. * Subtracts this CSG with another CSG in place
  48691. * @param csg The CSG to subtact against this CSG
  48692. */
  48693. subtractInPlace(csg: CSG): void;
  48694. /**
  48695. * Intersect this CSG with another CSG
  48696. * @param csg The CSG to intersect against this CSG
  48697. * @returns A new CSG
  48698. */
  48699. intersect(csg: CSG): CSG;
  48700. /**
  48701. * Intersects this CSG with another CSG in place
  48702. * @param csg The CSG to intersect against this CSG
  48703. */
  48704. intersectInPlace(csg: CSG): void;
  48705. /**
  48706. * Return a new CSG solid with solid and empty space switched. This solid is
  48707. * not modified.
  48708. * @returns A new CSG solid with solid and empty space switched
  48709. */
  48710. inverse(): CSG;
  48711. /**
  48712. * Inverses the CSG in place
  48713. */
  48714. inverseInPlace(): void;
  48715. /**
  48716. * This is used to keep meshes transformations so they can be restored
  48717. * when we build back a Babylon Mesh
  48718. * NB : All CSG operations are performed in world coordinates
  48719. * @param csg The CSG to copy the transform attributes from
  48720. * @returns This CSG
  48721. */
  48722. copyTransformAttributes(csg: CSG): CSG;
  48723. /**
  48724. * Build Raw mesh from CSG
  48725. * Coordinates here are in world space
  48726. * @param name The name of the mesh geometry
  48727. * @param scene The Scene
  48728. * @param keepSubMeshes Specifies if the submeshes should be kept
  48729. * @returns A new Mesh
  48730. */
  48731. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  48732. /**
  48733. * Build Mesh from CSG taking material and transforms into account
  48734. * @param name The name of the Mesh
  48735. * @param material The material of the Mesh
  48736. * @param scene The Scene
  48737. * @param keepSubMeshes Specifies if submeshes should be kept
  48738. * @returns The new Mesh
  48739. */
  48740. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  48741. }
  48742. }
  48743. declare module BABYLON {
  48744. /**
  48745. * Class used to create a trail following a mesh
  48746. */
  48747. export class TrailMesh extends Mesh {
  48748. private _generator;
  48749. private _autoStart;
  48750. private _running;
  48751. private _diameter;
  48752. private _length;
  48753. private _sectionPolygonPointsCount;
  48754. private _sectionVectors;
  48755. private _sectionNormalVectors;
  48756. private _beforeRenderObserver;
  48757. /**
  48758. * @constructor
  48759. * @param name The value used by scene.getMeshByName() to do a lookup.
  48760. * @param generator The mesh to generate a trail.
  48761. * @param scene The scene to add this mesh to.
  48762. * @param diameter Diameter of trailing mesh. Default is 1.
  48763. * @param length Length of trailing mesh. Default is 60.
  48764. * @param autoStart Automatically start trailing mesh. Default true.
  48765. */
  48766. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  48767. /**
  48768. * "TrailMesh"
  48769. * @returns "TrailMesh"
  48770. */
  48771. getClassName(): string;
  48772. private _createMesh;
  48773. /**
  48774. * Start trailing mesh.
  48775. */
  48776. start(): void;
  48777. /**
  48778. * Stop trailing mesh.
  48779. */
  48780. stop(): void;
  48781. /**
  48782. * Update trailing mesh geometry.
  48783. */
  48784. update(): void;
  48785. /**
  48786. * Returns a new TrailMesh object.
  48787. * @param name is a string, the name given to the new mesh
  48788. * @param newGenerator use new generator object for cloned trail mesh
  48789. * @returns a new mesh
  48790. */
  48791. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  48792. /**
  48793. * Serializes this trail mesh
  48794. * @param serializationObject object to write serialization to
  48795. */
  48796. serialize(serializationObject: any): void;
  48797. /**
  48798. * Parses a serialized trail mesh
  48799. * @param parsedMesh the serialized mesh
  48800. * @param scene the scene to create the trail mesh in
  48801. * @returns the created trail mesh
  48802. */
  48803. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  48804. }
  48805. }
  48806. declare module BABYLON {
  48807. /**
  48808. * Class containing static functions to help procedurally build meshes
  48809. */
  48810. export class TorusKnotBuilder {
  48811. /**
  48812. * Creates a torus knot mesh
  48813. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  48814. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  48815. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  48816. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  48817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48818. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48820. * @param name defines the name of the mesh
  48821. * @param options defines the options used to create the mesh
  48822. * @param scene defines the hosting scene
  48823. * @returns the torus knot mesh
  48824. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  48825. */
  48826. static CreateTorusKnot(name: string, options: {
  48827. radius?: number;
  48828. tube?: number;
  48829. radialSegments?: number;
  48830. tubularSegments?: number;
  48831. p?: number;
  48832. q?: number;
  48833. updatable?: boolean;
  48834. sideOrientation?: number;
  48835. frontUVs?: Vector4;
  48836. backUVs?: Vector4;
  48837. }, scene: any): Mesh;
  48838. }
  48839. }
  48840. declare module BABYLON {
  48841. /**
  48842. * Polygon
  48843. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  48844. */
  48845. export class Polygon {
  48846. /**
  48847. * Creates a rectangle
  48848. * @param xmin bottom X coord
  48849. * @param ymin bottom Y coord
  48850. * @param xmax top X coord
  48851. * @param ymax top Y coord
  48852. * @returns points that make the resulting rectation
  48853. */
  48854. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  48855. /**
  48856. * Creates a circle
  48857. * @param radius radius of circle
  48858. * @param cx scale in x
  48859. * @param cy scale in y
  48860. * @param numberOfSides number of sides that make up the circle
  48861. * @returns points that make the resulting circle
  48862. */
  48863. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  48864. /**
  48865. * Creates a polygon from input string
  48866. * @param input Input polygon data
  48867. * @returns the parsed points
  48868. */
  48869. static Parse(input: string): Vector2[];
  48870. /**
  48871. * Starts building a polygon from x and y coordinates
  48872. * @param x x coordinate
  48873. * @param y y coordinate
  48874. * @returns the started path2
  48875. */
  48876. static StartingAt(x: number, y: number): Path2;
  48877. }
  48878. /**
  48879. * Builds a polygon
  48880. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  48881. */
  48882. export class PolygonMeshBuilder {
  48883. private _points;
  48884. private _outlinepoints;
  48885. private _holes;
  48886. private _name;
  48887. private _scene;
  48888. private _epoints;
  48889. private _eholes;
  48890. private _addToepoint;
  48891. /**
  48892. * Babylon reference to the earcut plugin.
  48893. */
  48894. bjsEarcut: any;
  48895. /**
  48896. * Creates a PolygonMeshBuilder
  48897. * @param name name of the builder
  48898. * @param contours Path of the polygon
  48899. * @param scene scene to add to when creating the mesh
  48900. * @param earcutInjection can be used to inject your own earcut reference
  48901. */
  48902. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  48903. /**
  48904. * Adds a whole within the polygon
  48905. * @param hole Array of points defining the hole
  48906. * @returns this
  48907. */
  48908. addHole(hole: Vector2[]): PolygonMeshBuilder;
  48909. /**
  48910. * Creates the polygon
  48911. * @param updatable If the mesh should be updatable
  48912. * @param depth The depth of the mesh created
  48913. * @returns the created mesh
  48914. */
  48915. build(updatable?: boolean, depth?: number): Mesh;
  48916. /**
  48917. * Creates the polygon
  48918. * @param depth The depth of the mesh created
  48919. * @returns the created VertexData
  48920. */
  48921. buildVertexData(depth?: number): VertexData;
  48922. /**
  48923. * Adds a side to the polygon
  48924. * @param positions points that make the polygon
  48925. * @param normals normals of the polygon
  48926. * @param uvs uvs of the polygon
  48927. * @param indices indices of the polygon
  48928. * @param bounds bounds of the polygon
  48929. * @param points points of the polygon
  48930. * @param depth depth of the polygon
  48931. * @param flip flip of the polygon
  48932. */
  48933. private addSide;
  48934. }
  48935. }
  48936. declare module BABYLON {
  48937. /**
  48938. * Class containing static functions to help procedurally build meshes
  48939. */
  48940. export class PolygonBuilder {
  48941. /**
  48942. * Creates a polygon mesh
  48943. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  48944. * * 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
  48945. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  48946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  48948. * * Remember you can only change the shape positions, not their number when updating a polygon
  48949. * @param name defines the name of the mesh
  48950. * @param options defines the options used to create the mesh
  48951. * @param scene defines the hosting scene
  48952. * @param earcutInjection can be used to inject your own earcut reference
  48953. * @returns the polygon mesh
  48954. */
  48955. static CreatePolygon(name: string, options: {
  48956. shape: Vector3[];
  48957. holes?: Vector3[][];
  48958. depth?: number;
  48959. faceUV?: Vector4[];
  48960. faceColors?: Color4[];
  48961. updatable?: boolean;
  48962. sideOrientation?: number;
  48963. frontUVs?: Vector4;
  48964. backUVs?: Vector4;
  48965. }, scene: Scene, earcutInjection?: any): Mesh;
  48966. /**
  48967. * Creates an extruded polygon mesh, with depth in the Y direction.
  48968. * * 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)
  48969. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48970. * @param name defines the name of the mesh
  48971. * @param options defines the options used to create the mesh
  48972. * @param scene defines the hosting scene
  48973. * @param earcutInjection can be used to inject your own earcut reference
  48974. * @returns the polygon mesh
  48975. */
  48976. static ExtrudePolygon(name: string, options: {
  48977. shape: Vector3[];
  48978. holes?: Vector3[][];
  48979. depth?: number;
  48980. faceUV?: Vector4[];
  48981. faceColors?: Color4[];
  48982. updatable?: boolean;
  48983. sideOrientation?: number;
  48984. frontUVs?: Vector4;
  48985. backUVs?: Vector4;
  48986. }, scene: Scene, earcutInjection?: any): Mesh;
  48987. }
  48988. }
  48989. declare module BABYLON {
  48990. /**
  48991. * Class containing static functions to help procedurally build meshes
  48992. */
  48993. export class LatheBuilder {
  48994. /**
  48995. * Creates lathe mesh.
  48996. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  48997. * * 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
  48998. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  48999. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49000. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49001. * * 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
  49002. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49003. * * 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
  49004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49005. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49006. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49008. * @param name defines the name of the mesh
  49009. * @param options defines the options used to create the mesh
  49010. * @param scene defines the hosting scene
  49011. * @returns the lathe mesh
  49012. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49013. */
  49014. static CreateLathe(name: string, options: {
  49015. shape: Vector3[];
  49016. radius?: number;
  49017. tessellation?: number;
  49018. clip?: number;
  49019. arc?: number;
  49020. closed?: boolean;
  49021. updatable?: boolean;
  49022. sideOrientation?: number;
  49023. frontUVs?: Vector4;
  49024. backUVs?: Vector4;
  49025. cap?: number;
  49026. invertUV?: boolean;
  49027. }, scene: Scene): Mesh;
  49028. }
  49029. }
  49030. declare module BABYLON {
  49031. /**
  49032. * Class containing static functions to help procedurally build meshes
  49033. */
  49034. export class TubeBuilder {
  49035. /**
  49036. * Creates a tube mesh.
  49037. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49038. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49039. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49040. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49041. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49042. * * 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)
  49043. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49044. * * 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
  49045. * * 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
  49046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49047. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49048. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49050. * @param name defines the name of the mesh
  49051. * @param options defines the options used to create the mesh
  49052. * @param scene defines the hosting scene
  49053. * @returns the tube mesh
  49054. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49055. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49056. */
  49057. static CreateTube(name: string, options: {
  49058. path: Vector3[];
  49059. radius?: number;
  49060. tessellation?: number;
  49061. radiusFunction?: {
  49062. (i: number, distance: number): number;
  49063. };
  49064. cap?: number;
  49065. arc?: number;
  49066. updatable?: boolean;
  49067. sideOrientation?: number;
  49068. frontUVs?: Vector4;
  49069. backUVs?: Vector4;
  49070. instance?: Mesh;
  49071. invertUV?: boolean;
  49072. }, scene: Scene): Mesh;
  49073. }
  49074. }
  49075. declare module BABYLON {
  49076. /**
  49077. * Class containing static functions to help procedurally build meshes
  49078. */
  49079. export class IcoSphereBuilder {
  49080. /**
  49081. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49082. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49083. * * 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`)
  49084. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49085. * * 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
  49086. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49087. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49089. * @param name defines the name of the mesh
  49090. * @param options defines the options used to create the mesh
  49091. * @param scene defines the hosting scene
  49092. * @returns the icosahedron mesh
  49093. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49094. */
  49095. static CreateIcoSphere(name: string, options: {
  49096. radius?: number;
  49097. radiusX?: number;
  49098. radiusY?: number;
  49099. radiusZ?: number;
  49100. flat?: boolean;
  49101. subdivisions?: number;
  49102. sideOrientation?: number;
  49103. frontUVs?: Vector4;
  49104. backUVs?: Vector4;
  49105. updatable?: boolean;
  49106. }, scene: Scene): Mesh;
  49107. }
  49108. }
  49109. declare module BABYLON {
  49110. /**
  49111. * Class containing static functions to help procedurally build meshes
  49112. */
  49113. export class DecalBuilder {
  49114. /**
  49115. * Creates a decal mesh.
  49116. * 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
  49117. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49118. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49119. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49120. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49121. * @param name defines the name of the mesh
  49122. * @param sourceMesh defines the mesh where the decal must be applied
  49123. * @param options defines the options used to create the mesh
  49124. * @param scene defines the hosting scene
  49125. * @returns the decal mesh
  49126. * @see https://doc.babylonjs.com/how_to/decals
  49127. */
  49128. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49129. position?: Vector3;
  49130. normal?: Vector3;
  49131. size?: Vector3;
  49132. angle?: number;
  49133. }): Mesh;
  49134. }
  49135. }
  49136. declare module BABYLON {
  49137. /**
  49138. * Class containing static functions to help procedurally build meshes
  49139. */
  49140. export class MeshBuilder {
  49141. /**
  49142. * Creates a box mesh
  49143. * * The parameter `size` sets the size (float) of each box side (default 1)
  49144. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49145. * * 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)
  49146. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49147. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49148. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49150. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49151. * @param name defines the name of the mesh
  49152. * @param options defines the options used to create the mesh
  49153. * @param scene defines the hosting scene
  49154. * @returns the box mesh
  49155. */
  49156. static CreateBox(name: string, options: {
  49157. size?: number;
  49158. width?: number;
  49159. height?: number;
  49160. depth?: number;
  49161. faceUV?: Vector4[];
  49162. faceColors?: Color4[];
  49163. sideOrientation?: number;
  49164. frontUVs?: Vector4;
  49165. backUVs?: Vector4;
  49166. updatable?: boolean;
  49167. }, scene?: Nullable<Scene>): Mesh;
  49168. /**
  49169. * Creates a sphere mesh
  49170. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49171. * * 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`)
  49172. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49173. * * 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
  49174. * * 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)
  49175. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49176. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49178. * @param name defines the name of the mesh
  49179. * @param options defines the options used to create the mesh
  49180. * @param scene defines the hosting scene
  49181. * @returns the sphere mesh
  49182. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49183. */
  49184. static CreateSphere(name: string, options: {
  49185. segments?: number;
  49186. diameter?: number;
  49187. diameterX?: number;
  49188. diameterY?: number;
  49189. diameterZ?: number;
  49190. arc?: number;
  49191. slice?: number;
  49192. sideOrientation?: number;
  49193. frontUVs?: Vector4;
  49194. backUVs?: Vector4;
  49195. updatable?: boolean;
  49196. }, scene: any): Mesh;
  49197. /**
  49198. * Creates a plane polygonal mesh. By default, this is a disc
  49199. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49200. * * 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
  49201. * * 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
  49202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49205. * @param name defines the name of the mesh
  49206. * @param options defines the options used to create the mesh
  49207. * @param scene defines the hosting scene
  49208. * @returns the plane polygonal mesh
  49209. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49210. */
  49211. static CreateDisc(name: string, options: {
  49212. radius?: number;
  49213. tessellation?: number;
  49214. arc?: number;
  49215. updatable?: boolean;
  49216. sideOrientation?: number;
  49217. frontUVs?: Vector4;
  49218. backUVs?: Vector4;
  49219. }, scene?: Nullable<Scene>): Mesh;
  49220. /**
  49221. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49222. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49223. * * 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`)
  49224. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49225. * * 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
  49226. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49227. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49229. * @param name defines the name of the mesh
  49230. * @param options defines the options used to create the mesh
  49231. * @param scene defines the hosting scene
  49232. * @returns the icosahedron mesh
  49233. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49234. */
  49235. static CreateIcoSphere(name: string, options: {
  49236. radius?: number;
  49237. radiusX?: number;
  49238. radiusY?: number;
  49239. radiusZ?: number;
  49240. flat?: boolean;
  49241. subdivisions?: number;
  49242. sideOrientation?: number;
  49243. frontUVs?: Vector4;
  49244. backUVs?: Vector4;
  49245. updatable?: boolean;
  49246. }, scene: Scene): Mesh;
  49247. /**
  49248. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49249. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49250. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49251. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49252. * * 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
  49253. * * 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
  49254. * * 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
  49255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49256. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49257. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49258. * * 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
  49259. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49260. * * 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
  49261. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49263. * @param name defines the name of the mesh
  49264. * @param options defines the options used to create the mesh
  49265. * @param scene defines the hosting scene
  49266. * @returns the ribbon mesh
  49267. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49268. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49269. */
  49270. static CreateRibbon(name: string, options: {
  49271. pathArray: Vector3[][];
  49272. closeArray?: boolean;
  49273. closePath?: boolean;
  49274. offset?: number;
  49275. updatable?: boolean;
  49276. sideOrientation?: number;
  49277. frontUVs?: Vector4;
  49278. backUVs?: Vector4;
  49279. instance?: Mesh;
  49280. invertUV?: boolean;
  49281. uvs?: Vector2[];
  49282. colors?: Color4[];
  49283. }, scene?: Nullable<Scene>): Mesh;
  49284. /**
  49285. * Creates a cylinder or a cone mesh
  49286. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49287. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49288. * * 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.
  49289. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49290. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49291. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49292. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49293. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49294. * * 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).
  49295. * * 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
  49296. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49297. * * 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
  49298. * * 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.
  49299. * * If `enclose` is false, a ring surface is one element.
  49300. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49301. * * 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
  49302. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49303. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49305. * @param name defines the name of the mesh
  49306. * @param options defines the options used to create the mesh
  49307. * @param scene defines the hosting scene
  49308. * @returns the cylinder mesh
  49309. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49310. */
  49311. static CreateCylinder(name: string, options: {
  49312. height?: number;
  49313. diameterTop?: number;
  49314. diameterBottom?: number;
  49315. diameter?: number;
  49316. tessellation?: number;
  49317. subdivisions?: number;
  49318. arc?: number;
  49319. faceColors?: Color4[];
  49320. faceUV?: Vector4[];
  49321. updatable?: boolean;
  49322. hasRings?: boolean;
  49323. enclose?: boolean;
  49324. sideOrientation?: number;
  49325. frontUVs?: Vector4;
  49326. backUVs?: Vector4;
  49327. }, scene: any): Mesh;
  49328. /**
  49329. * Creates a torus mesh
  49330. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49331. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49332. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49334. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49336. * @param name defines the name of the mesh
  49337. * @param options defines the options used to create the mesh
  49338. * @param scene defines the hosting scene
  49339. * @returns the torus mesh
  49340. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49341. */
  49342. static CreateTorus(name: string, options: {
  49343. diameter?: number;
  49344. thickness?: number;
  49345. tessellation?: number;
  49346. updatable?: boolean;
  49347. sideOrientation?: number;
  49348. frontUVs?: Vector4;
  49349. backUVs?: Vector4;
  49350. }, scene: any): Mesh;
  49351. /**
  49352. * Creates a torus knot mesh
  49353. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49354. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49355. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49356. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49358. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49360. * @param name defines the name of the mesh
  49361. * @param options defines the options used to create the mesh
  49362. * @param scene defines the hosting scene
  49363. * @returns the torus knot mesh
  49364. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49365. */
  49366. static CreateTorusKnot(name: string, options: {
  49367. radius?: number;
  49368. tube?: number;
  49369. radialSegments?: number;
  49370. tubularSegments?: number;
  49371. p?: number;
  49372. q?: number;
  49373. updatable?: boolean;
  49374. sideOrientation?: number;
  49375. frontUVs?: Vector4;
  49376. backUVs?: Vector4;
  49377. }, scene: any): Mesh;
  49378. /**
  49379. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49380. * * 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
  49381. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49382. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49383. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49384. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49385. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49386. * * 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
  49387. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49389. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49390. * @param name defines the name of the new line system
  49391. * @param options defines the options used to create the line system
  49392. * @param scene defines the hosting scene
  49393. * @returns a new line system mesh
  49394. */
  49395. static CreateLineSystem(name: string, options: {
  49396. lines: Vector3[][];
  49397. updatable?: boolean;
  49398. instance?: Nullable<LinesMesh>;
  49399. colors?: Nullable<Color4[][]>;
  49400. useVertexAlpha?: boolean;
  49401. }, scene: Nullable<Scene>): LinesMesh;
  49402. /**
  49403. * Creates a line mesh
  49404. * 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
  49405. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49406. * * The parameter `points` is an array successive Vector3
  49407. * * 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
  49408. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49409. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49410. * * When updating an instance, remember that only point positions can change, not the number of points
  49411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49412. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49413. * @param name defines the name of the new line system
  49414. * @param options defines the options used to create the line system
  49415. * @param scene defines the hosting scene
  49416. * @returns a new line mesh
  49417. */
  49418. static CreateLines(name: string, options: {
  49419. points: Vector3[];
  49420. updatable?: boolean;
  49421. instance?: Nullable<LinesMesh>;
  49422. colors?: Color4[];
  49423. useVertexAlpha?: boolean;
  49424. }, scene?: Nullable<Scene>): LinesMesh;
  49425. /**
  49426. * Creates a dashed line mesh
  49427. * * 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
  49428. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49429. * * The parameter `points` is an array successive Vector3
  49430. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49431. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49432. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49433. * * 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
  49434. * * When updating an instance, remember that only point positions can change, not the number of points
  49435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49436. * @param name defines the name of the mesh
  49437. * @param options defines the options used to create the mesh
  49438. * @param scene defines the hosting scene
  49439. * @returns the dashed line mesh
  49440. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49441. */
  49442. static CreateDashedLines(name: string, options: {
  49443. points: Vector3[];
  49444. dashSize?: number;
  49445. gapSize?: number;
  49446. dashNb?: number;
  49447. updatable?: boolean;
  49448. instance?: LinesMesh;
  49449. }, scene?: Nullable<Scene>): LinesMesh;
  49450. /**
  49451. * 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.
  49452. * * 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.
  49453. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49454. * * 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.
  49455. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49456. * * 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
  49457. * * 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
  49458. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49461. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49463. * @param name defines the name of the mesh
  49464. * @param options defines the options used to create the mesh
  49465. * @param scene defines the hosting scene
  49466. * @returns the extruded shape mesh
  49467. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49468. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49469. */
  49470. static ExtrudeShape(name: string, options: {
  49471. shape: Vector3[];
  49472. path: Vector3[];
  49473. scale?: number;
  49474. rotation?: number;
  49475. cap?: number;
  49476. updatable?: boolean;
  49477. sideOrientation?: number;
  49478. frontUVs?: Vector4;
  49479. backUVs?: Vector4;
  49480. instance?: Mesh;
  49481. invertUV?: boolean;
  49482. }, scene?: Nullable<Scene>): Mesh;
  49483. /**
  49484. * Creates an custom extruded shape mesh.
  49485. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49486. * * 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.
  49487. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49488. * * 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
  49489. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49490. * * 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
  49491. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49492. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49493. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49494. * * 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
  49495. * * 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
  49496. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49499. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49501. * @param name defines the name of the mesh
  49502. * @param options defines the options used to create the mesh
  49503. * @param scene defines the hosting scene
  49504. * @returns the custom extruded shape mesh
  49505. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49506. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49507. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49508. */
  49509. static ExtrudeShapeCustom(name: string, options: {
  49510. shape: Vector3[];
  49511. path: Vector3[];
  49512. scaleFunction?: any;
  49513. rotationFunction?: any;
  49514. ribbonCloseArray?: boolean;
  49515. ribbonClosePath?: boolean;
  49516. cap?: number;
  49517. updatable?: boolean;
  49518. sideOrientation?: number;
  49519. frontUVs?: Vector4;
  49520. backUVs?: Vector4;
  49521. instance?: Mesh;
  49522. invertUV?: boolean;
  49523. }, scene: Scene): Mesh;
  49524. /**
  49525. * Creates lathe mesh.
  49526. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49527. * * 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
  49528. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49529. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49530. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49531. * * 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
  49532. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49533. * * 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
  49534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49535. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49536. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49538. * @param name defines the name of the mesh
  49539. * @param options defines the options used to create the mesh
  49540. * @param scene defines the hosting scene
  49541. * @returns the lathe mesh
  49542. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49543. */
  49544. static CreateLathe(name: string, options: {
  49545. shape: Vector3[];
  49546. radius?: number;
  49547. tessellation?: number;
  49548. clip?: number;
  49549. arc?: number;
  49550. closed?: boolean;
  49551. updatable?: boolean;
  49552. sideOrientation?: number;
  49553. frontUVs?: Vector4;
  49554. backUVs?: Vector4;
  49555. cap?: number;
  49556. invertUV?: boolean;
  49557. }, scene: Scene): Mesh;
  49558. /**
  49559. * Creates a plane mesh
  49560. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49561. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49562. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  49563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49564. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49566. * @param name defines the name of the mesh
  49567. * @param options defines the options used to create the mesh
  49568. * @param scene defines the hosting scene
  49569. * @returns the plane mesh
  49570. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  49571. */
  49572. static CreatePlane(name: string, options: {
  49573. size?: number;
  49574. width?: number;
  49575. height?: number;
  49576. sideOrientation?: number;
  49577. frontUVs?: Vector4;
  49578. backUVs?: Vector4;
  49579. updatable?: boolean;
  49580. sourcePlane?: Plane;
  49581. }, scene: Scene): Mesh;
  49582. /**
  49583. * Creates a ground mesh
  49584. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49585. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49587. * @param name defines the name of the mesh
  49588. * @param options defines the options used to create the mesh
  49589. * @param scene defines the hosting scene
  49590. * @returns the ground mesh
  49591. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49592. */
  49593. static CreateGround(name: string, options: {
  49594. width?: number;
  49595. height?: number;
  49596. subdivisions?: number;
  49597. subdivisionsX?: number;
  49598. subdivisionsY?: number;
  49599. updatable?: boolean;
  49600. }, scene: any): Mesh;
  49601. /**
  49602. * Creates a tiled ground mesh
  49603. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49604. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49605. * * 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
  49606. * * 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
  49607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49608. * @param name defines the name of the mesh
  49609. * @param options defines the options used to create the mesh
  49610. * @param scene defines the hosting scene
  49611. * @returns the tiled ground mesh
  49612. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49613. */
  49614. static CreateTiledGround(name: string, options: {
  49615. xmin: number;
  49616. zmin: number;
  49617. xmax: number;
  49618. zmax: number;
  49619. subdivisions?: {
  49620. w: number;
  49621. h: number;
  49622. };
  49623. precision?: {
  49624. w: number;
  49625. h: number;
  49626. };
  49627. updatable?: boolean;
  49628. }, scene: Scene): Mesh;
  49629. /**
  49630. * Creates a ground mesh from a height map
  49631. * * The parameter `url` sets the URL of the height map image resource.
  49632. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49633. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49634. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49635. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49636. * * 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.
  49637. * * 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).
  49638. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49640. * @param name defines the name of the mesh
  49641. * @param url defines the url to the height map
  49642. * @param options defines the options used to create the mesh
  49643. * @param scene defines the hosting scene
  49644. * @returns the ground mesh
  49645. * @see https://doc.babylonjs.com/babylon101/height_map
  49646. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  49647. */
  49648. static CreateGroundFromHeightMap(name: string, url: string, options: {
  49649. width?: number;
  49650. height?: number;
  49651. subdivisions?: number;
  49652. minHeight?: number;
  49653. maxHeight?: number;
  49654. colorFilter?: Color3;
  49655. alphaFilter?: number;
  49656. updatable?: boolean;
  49657. onReady?: (mesh: GroundMesh) => void;
  49658. }, scene: Scene): GroundMesh;
  49659. /**
  49660. * Creates a polygon mesh
  49661. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49662. * * 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
  49663. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49665. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  49666. * * Remember you can only change the shape positions, not their number when updating a polygon
  49667. * @param name defines the name of the mesh
  49668. * @param options defines the options used to create the mesh
  49669. * @param scene defines the hosting scene
  49670. * @param earcutInjection can be used to inject your own earcut reference
  49671. * @returns the polygon mesh
  49672. */
  49673. static CreatePolygon(name: string, options: {
  49674. shape: Vector3[];
  49675. holes?: Vector3[][];
  49676. depth?: number;
  49677. faceUV?: Vector4[];
  49678. faceColors?: Color4[];
  49679. updatable?: boolean;
  49680. sideOrientation?: number;
  49681. frontUVs?: Vector4;
  49682. backUVs?: Vector4;
  49683. }, scene: Scene, earcutInjection?: any): Mesh;
  49684. /**
  49685. * Creates an extruded polygon mesh, with depth in the Y direction.
  49686. * * 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)
  49687. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49688. * @param name defines the name of the mesh
  49689. * @param options defines the options used to create the mesh
  49690. * @param scene defines the hosting scene
  49691. * @param earcutInjection can be used to inject your own earcut reference
  49692. * @returns the polygon mesh
  49693. */
  49694. static ExtrudePolygon(name: string, options: {
  49695. shape: Vector3[];
  49696. holes?: Vector3[][];
  49697. depth?: number;
  49698. faceUV?: Vector4[];
  49699. faceColors?: Color4[];
  49700. updatable?: boolean;
  49701. sideOrientation?: number;
  49702. frontUVs?: Vector4;
  49703. backUVs?: Vector4;
  49704. }, scene: Scene, earcutInjection?: any): Mesh;
  49705. /**
  49706. * Creates a tube mesh.
  49707. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49708. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49709. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49710. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49711. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49712. * * 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)
  49713. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49714. * * 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
  49715. * * 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
  49716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49717. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49718. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49720. * @param name defines the name of the mesh
  49721. * @param options defines the options used to create the mesh
  49722. * @param scene defines the hosting scene
  49723. * @returns the tube mesh
  49724. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49725. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49726. */
  49727. static CreateTube(name: string, options: {
  49728. path: Vector3[];
  49729. radius?: number;
  49730. tessellation?: number;
  49731. radiusFunction?: {
  49732. (i: number, distance: number): number;
  49733. };
  49734. cap?: number;
  49735. arc?: number;
  49736. updatable?: boolean;
  49737. sideOrientation?: number;
  49738. frontUVs?: Vector4;
  49739. backUVs?: Vector4;
  49740. instance?: Mesh;
  49741. invertUV?: boolean;
  49742. }, scene: Scene): Mesh;
  49743. /**
  49744. * Creates a polyhedron mesh
  49745. * * 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
  49746. * * The parameter `size` (positive float, default 1) sets the polygon size
  49747. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49748. * * 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`
  49749. * * 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
  49750. * * 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)`)
  49751. * * 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
  49752. * * 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
  49753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49754. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49756. * @param name defines the name of the mesh
  49757. * @param options defines the options used to create the mesh
  49758. * @param scene defines the hosting scene
  49759. * @returns the polyhedron mesh
  49760. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49761. */
  49762. static CreatePolyhedron(name: string, options: {
  49763. type?: number;
  49764. size?: number;
  49765. sizeX?: number;
  49766. sizeY?: number;
  49767. sizeZ?: number;
  49768. custom?: any;
  49769. faceUV?: Vector4[];
  49770. faceColors?: Color4[];
  49771. flat?: boolean;
  49772. updatable?: boolean;
  49773. sideOrientation?: number;
  49774. frontUVs?: Vector4;
  49775. backUVs?: Vector4;
  49776. }, scene: Scene): Mesh;
  49777. /**
  49778. * Creates a decal mesh.
  49779. * 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
  49780. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49781. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49782. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49783. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49784. * @param name defines the name of the mesh
  49785. * @param sourceMesh defines the mesh where the decal must be applied
  49786. * @param options defines the options used to create the mesh
  49787. * @param scene defines the hosting scene
  49788. * @returns the decal mesh
  49789. * @see https://doc.babylonjs.com/how_to/decals
  49790. */
  49791. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49792. position?: Vector3;
  49793. normal?: Vector3;
  49794. size?: Vector3;
  49795. angle?: number;
  49796. }): Mesh;
  49797. }
  49798. }
  49799. declare module BABYLON {
  49800. /**
  49801. * A simplifier interface for future simplification implementations
  49802. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49803. */
  49804. export interface ISimplifier {
  49805. /**
  49806. * Simplification of a given mesh according to the given settings.
  49807. * Since this requires computation, it is assumed that the function runs async.
  49808. * @param settings The settings of the simplification, including quality and distance
  49809. * @param successCallback A callback that will be called after the mesh was simplified.
  49810. * @param errorCallback in case of an error, this callback will be called. optional.
  49811. */
  49812. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  49813. }
  49814. /**
  49815. * Expected simplification settings.
  49816. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  49817. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49818. */
  49819. export interface ISimplificationSettings {
  49820. /**
  49821. * Gets or sets the expected quality
  49822. */
  49823. quality: number;
  49824. /**
  49825. * Gets or sets the distance when this optimized version should be used
  49826. */
  49827. distance: number;
  49828. /**
  49829. * Gets an already optimized mesh
  49830. */
  49831. optimizeMesh?: boolean;
  49832. }
  49833. /**
  49834. * Class used to specify simplification options
  49835. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49836. */
  49837. export class SimplificationSettings implements ISimplificationSettings {
  49838. /** expected quality */
  49839. quality: number;
  49840. /** distance when this optimized version should be used */
  49841. distance: number;
  49842. /** already optimized mesh */
  49843. optimizeMesh?: boolean | undefined;
  49844. /**
  49845. * Creates a SimplificationSettings
  49846. * @param quality expected quality
  49847. * @param distance distance when this optimized version should be used
  49848. * @param optimizeMesh already optimized mesh
  49849. */
  49850. constructor(
  49851. /** expected quality */
  49852. quality: number,
  49853. /** distance when this optimized version should be used */
  49854. distance: number,
  49855. /** already optimized mesh */
  49856. optimizeMesh?: boolean | undefined);
  49857. }
  49858. /**
  49859. * Interface used to define a simplification task
  49860. */
  49861. export interface ISimplificationTask {
  49862. /**
  49863. * Array of settings
  49864. */
  49865. settings: Array<ISimplificationSettings>;
  49866. /**
  49867. * Simplification type
  49868. */
  49869. simplificationType: SimplificationType;
  49870. /**
  49871. * Mesh to simplify
  49872. */
  49873. mesh: Mesh;
  49874. /**
  49875. * Callback called on success
  49876. */
  49877. successCallback?: () => void;
  49878. /**
  49879. * Defines if parallel processing can be used
  49880. */
  49881. parallelProcessing: boolean;
  49882. }
  49883. /**
  49884. * Queue used to order the simplification tasks
  49885. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49886. */
  49887. export class SimplificationQueue {
  49888. private _simplificationArray;
  49889. /**
  49890. * Gets a boolean indicating that the process is still running
  49891. */
  49892. running: boolean;
  49893. /**
  49894. * Creates a new queue
  49895. */
  49896. constructor();
  49897. /**
  49898. * Adds a new simplification task
  49899. * @param task defines a task to add
  49900. */
  49901. addTask(task: ISimplificationTask): void;
  49902. /**
  49903. * Execute next task
  49904. */
  49905. executeNext(): void;
  49906. /**
  49907. * Execute a simplification task
  49908. * @param task defines the task to run
  49909. */
  49910. runSimplification(task: ISimplificationTask): void;
  49911. private getSimplifier;
  49912. }
  49913. /**
  49914. * The implemented types of simplification
  49915. * At the moment only Quadratic Error Decimation is implemented
  49916. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49917. */
  49918. export enum SimplificationType {
  49919. /** Quadratic error decimation */
  49920. QUADRATIC = 0
  49921. }
  49922. }
  49923. declare module BABYLON {
  49924. interface Scene {
  49925. /** @hidden (Backing field) */ simplificationQueue: SimplificationQueue;
  49926. /**
  49927. * Gets or sets the simplification queue attached to the scene
  49928. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49929. */
  49930. simplificationQueue: SimplificationQueue;
  49931. }
  49932. interface Mesh {
  49933. /**
  49934. * Simplify the mesh according to the given array of settings.
  49935. * Function will return immediately and will simplify async
  49936. * @param settings a collection of simplification settings
  49937. * @param parallelProcessing should all levels calculate parallel or one after the other
  49938. * @param simplificationType the type of simplification to run
  49939. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  49940. * @returns the current mesh
  49941. */
  49942. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  49943. }
  49944. /**
  49945. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  49946. * created in a scene
  49947. */
  49948. export class SimplicationQueueSceneComponent implements ISceneComponent {
  49949. /**
  49950. * The component name helpfull to identify the component in the list of scene components.
  49951. */
  49952. readonly name: string;
  49953. /**
  49954. * The scene the component belongs to.
  49955. */
  49956. scene: Scene;
  49957. /**
  49958. * Creates a new instance of the component for the given scene
  49959. * @param scene Defines the scene to register the component in
  49960. */
  49961. constructor(scene: Scene);
  49962. /**
  49963. * Registers the component in a given scene
  49964. */
  49965. register(): void;
  49966. /**
  49967. * Rebuilds the elements related to this component in case of
  49968. * context lost for instance.
  49969. */
  49970. rebuild(): void;
  49971. /**
  49972. * Disposes the component and the associated ressources
  49973. */
  49974. dispose(): void;
  49975. private _beforeCameraUpdate;
  49976. }
  49977. }
  49978. declare module BABYLON {
  49979. /**
  49980. * Class used to enable access to IndexedDB
  49981. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  49982. */
  49983. export class Database implements IOfflineProvider {
  49984. private _callbackManifestChecked;
  49985. private _currentSceneUrl;
  49986. private _db;
  49987. private _enableSceneOffline;
  49988. private _enableTexturesOffline;
  49989. private _manifestVersionFound;
  49990. private _mustUpdateRessources;
  49991. private _hasReachedQuota;
  49992. private _isSupported;
  49993. private _idbFactory;
  49994. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  49995. private static IsUASupportingBlobStorage;
  49996. /**
  49997. * Gets a boolean indicating if Database storate is enabled (off by default)
  49998. */
  49999. static IDBStorageEnabled: boolean;
  50000. /**
  50001. * Gets a boolean indicating if scene must be saved in the database
  50002. */
  50003. readonly enableSceneOffline: boolean;
  50004. /**
  50005. * Gets a boolean indicating if textures must be saved in the database
  50006. */
  50007. readonly enableTexturesOffline: boolean;
  50008. /**
  50009. * Creates a new Database
  50010. * @param urlToScene defines the url to load the scene
  50011. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50012. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50013. */
  50014. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50015. private static _ParseURL;
  50016. private static _ReturnFullUrlLocation;
  50017. private _checkManifestFile;
  50018. /**
  50019. * Open the database and make it available
  50020. * @param successCallback defines the callback to call on success
  50021. * @param errorCallback defines the callback to call on error
  50022. */
  50023. open(successCallback: () => void, errorCallback: () => void): void;
  50024. /**
  50025. * Loads an image from the database
  50026. * @param url defines the url to load from
  50027. * @param image defines the target DOM image
  50028. */
  50029. loadImage(url: string, image: HTMLImageElement): void;
  50030. private _loadImageFromDBAsync;
  50031. private _saveImageIntoDBAsync;
  50032. private _checkVersionFromDB;
  50033. private _loadVersionFromDBAsync;
  50034. private _saveVersionIntoDBAsync;
  50035. /**
  50036. * Loads a file from database
  50037. * @param url defines the URL to load from
  50038. * @param sceneLoaded defines a callback to call on success
  50039. * @param progressCallBack defines a callback to call when progress changed
  50040. * @param errorCallback defines a callback to call on error
  50041. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50042. */
  50043. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50044. private _loadFileAsync;
  50045. private _saveFileAsync;
  50046. /**
  50047. * Validates if xhr data is correct
  50048. * @param xhr defines the request to validate
  50049. * @param dataType defines the expected data type
  50050. * @returns true if data is correct
  50051. */
  50052. private static _ValidateXHRData;
  50053. }
  50054. }
  50055. declare module BABYLON {
  50056. /** @hidden */
  50057. export var gpuUpdateParticlesPixelShader: {
  50058. name: string;
  50059. shader: string;
  50060. };
  50061. }
  50062. declare module BABYLON {
  50063. /** @hidden */
  50064. export var gpuUpdateParticlesVertexShader: {
  50065. name: string;
  50066. shader: string;
  50067. };
  50068. }
  50069. declare module BABYLON {
  50070. /** @hidden */
  50071. export var clipPlaneFragmentDeclaration2: {
  50072. name: string;
  50073. shader: string;
  50074. };
  50075. }
  50076. declare module BABYLON {
  50077. /** @hidden */
  50078. export var gpuRenderParticlesPixelShader: {
  50079. name: string;
  50080. shader: string;
  50081. };
  50082. }
  50083. declare module BABYLON {
  50084. /** @hidden */
  50085. export var clipPlaneVertexDeclaration2: {
  50086. name: string;
  50087. shader: string;
  50088. };
  50089. }
  50090. declare module BABYLON {
  50091. /** @hidden */
  50092. export var gpuRenderParticlesVertexShader: {
  50093. name: string;
  50094. shader: string;
  50095. };
  50096. }
  50097. declare module BABYLON {
  50098. /**
  50099. * This represents a GPU particle system in Babylon
  50100. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50101. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50102. */
  50103. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50104. /**
  50105. * The layer mask we are rendering the particles through.
  50106. */
  50107. layerMask: number;
  50108. private _capacity;
  50109. private _activeCount;
  50110. private _currentActiveCount;
  50111. private _accumulatedCount;
  50112. private _renderEffect;
  50113. private _updateEffect;
  50114. private _buffer0;
  50115. private _buffer1;
  50116. private _spriteBuffer;
  50117. private _updateVAO;
  50118. private _renderVAO;
  50119. private _targetIndex;
  50120. private _sourceBuffer;
  50121. private _targetBuffer;
  50122. private _engine;
  50123. private _currentRenderId;
  50124. private _started;
  50125. private _stopped;
  50126. private _timeDelta;
  50127. private _randomTexture;
  50128. private _randomTexture2;
  50129. private _attributesStrideSize;
  50130. private _updateEffectOptions;
  50131. private _randomTextureSize;
  50132. private _actualFrame;
  50133. private readonly _rawTextureWidth;
  50134. /**
  50135. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50136. */
  50137. static readonly IsSupported: boolean;
  50138. /**
  50139. * An event triggered when the system is disposed.
  50140. */
  50141. onDisposeObservable: Observable<GPUParticleSystem>;
  50142. /**
  50143. * Gets the maximum number of particles active at the same time.
  50144. * @returns The max number of active particles.
  50145. */
  50146. getCapacity(): number;
  50147. /**
  50148. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50149. * to override the particles.
  50150. */
  50151. forceDepthWrite: boolean;
  50152. /**
  50153. * Gets or set the number of active particles
  50154. */
  50155. activeParticleCount: number;
  50156. private _preWarmDone;
  50157. /**
  50158. * Is this system ready to be used/rendered
  50159. * @return true if the system is ready
  50160. */
  50161. isReady(): boolean;
  50162. /**
  50163. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50164. * @returns True if it has been started, otherwise false.
  50165. */
  50166. isStarted(): boolean;
  50167. /**
  50168. * Starts the particle system and begins to emit
  50169. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50170. */
  50171. start(delay?: number): void;
  50172. /**
  50173. * Stops the particle system.
  50174. */
  50175. stop(): void;
  50176. /**
  50177. * Remove all active particles
  50178. */
  50179. reset(): void;
  50180. /**
  50181. * Returns the string "GPUParticleSystem"
  50182. * @returns a string containing the class name
  50183. */
  50184. getClassName(): string;
  50185. private _colorGradientsTexture;
  50186. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50187. /**
  50188. * Adds a new color gradient
  50189. * @param gradient defines the gradient to use (between 0 and 1)
  50190. * @param color1 defines the color to affect to the specified gradient
  50191. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50192. * @returns the current particle system
  50193. */
  50194. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50195. /**
  50196. * Remove a specific color gradient
  50197. * @param gradient defines the gradient to remove
  50198. * @returns the current particle system
  50199. */
  50200. removeColorGradient(gradient: number): GPUParticleSystem;
  50201. private _angularSpeedGradientsTexture;
  50202. private _sizeGradientsTexture;
  50203. private _velocityGradientsTexture;
  50204. private _limitVelocityGradientsTexture;
  50205. private _dragGradientsTexture;
  50206. private _addFactorGradient;
  50207. /**
  50208. * Adds a new size gradient
  50209. * @param gradient defines the gradient to use (between 0 and 1)
  50210. * @param factor defines the size factor to affect to the specified gradient
  50211. * @returns the current particle system
  50212. */
  50213. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50214. /**
  50215. * Remove a specific size gradient
  50216. * @param gradient defines the gradient to remove
  50217. * @returns the current particle system
  50218. */
  50219. removeSizeGradient(gradient: number): GPUParticleSystem;
  50220. /**
  50221. * Adds a new angular speed gradient
  50222. * @param gradient defines the gradient to use (between 0 and 1)
  50223. * @param factor defines the angular speed to affect to the specified gradient
  50224. * @returns the current particle system
  50225. */
  50226. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50227. /**
  50228. * Remove a specific angular speed gradient
  50229. * @param gradient defines the gradient to remove
  50230. * @returns the current particle system
  50231. */
  50232. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50233. /**
  50234. * Adds a new velocity gradient
  50235. * @param gradient defines the gradient to use (between 0 and 1)
  50236. * @param factor defines the velocity to affect to the specified gradient
  50237. * @returns the current particle system
  50238. */
  50239. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50240. /**
  50241. * Remove a specific velocity gradient
  50242. * @param gradient defines the gradient to remove
  50243. * @returns the current particle system
  50244. */
  50245. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50246. /**
  50247. * Adds a new limit velocity gradient
  50248. * @param gradient defines the gradient to use (between 0 and 1)
  50249. * @param factor defines the limit velocity value to affect to the specified gradient
  50250. * @returns the current particle system
  50251. */
  50252. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50253. /**
  50254. * Remove a specific limit velocity gradient
  50255. * @param gradient defines the gradient to remove
  50256. * @returns the current particle system
  50257. */
  50258. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50259. /**
  50260. * Adds a new drag gradient
  50261. * @param gradient defines the gradient to use (between 0 and 1)
  50262. * @param factor defines the drag value to affect to the specified gradient
  50263. * @returns the current particle system
  50264. */
  50265. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50266. /**
  50267. * Remove a specific drag gradient
  50268. * @param gradient defines the gradient to remove
  50269. * @returns the current particle system
  50270. */
  50271. removeDragGradient(gradient: number): GPUParticleSystem;
  50272. /**
  50273. * Not supported by GPUParticleSystem
  50274. * @param gradient defines the gradient to use (between 0 and 1)
  50275. * @param factor defines the emit rate value to affect to the specified gradient
  50276. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50277. * @returns the current particle system
  50278. */
  50279. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50280. /**
  50281. * Not supported by GPUParticleSystem
  50282. * @param gradient defines the gradient to remove
  50283. * @returns the current particle system
  50284. */
  50285. removeEmitRateGradient(gradient: number): IParticleSystem;
  50286. /**
  50287. * Not supported by GPUParticleSystem
  50288. * @param gradient defines the gradient to use (between 0 and 1)
  50289. * @param factor defines the start size value to affect to the specified gradient
  50290. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50291. * @returns the current particle system
  50292. */
  50293. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50294. /**
  50295. * Not supported by GPUParticleSystem
  50296. * @param gradient defines the gradient to remove
  50297. * @returns the current particle system
  50298. */
  50299. removeStartSizeGradient(gradient: number): IParticleSystem;
  50300. /**
  50301. * Not supported by GPUParticleSystem
  50302. * @param gradient defines the gradient to use (between 0 and 1)
  50303. * @param min defines the color remap minimal range
  50304. * @param max defines the color remap maximal range
  50305. * @returns the current particle system
  50306. */
  50307. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50308. /**
  50309. * Not supported by GPUParticleSystem
  50310. * @param gradient defines the gradient to remove
  50311. * @returns the current particle system
  50312. */
  50313. removeColorRemapGradient(): IParticleSystem;
  50314. /**
  50315. * Not supported by GPUParticleSystem
  50316. * @param gradient defines the gradient to use (between 0 and 1)
  50317. * @param min defines the alpha remap minimal range
  50318. * @param max defines the alpha remap maximal range
  50319. * @returns the current particle system
  50320. */
  50321. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50322. /**
  50323. * Not supported by GPUParticleSystem
  50324. * @param gradient defines the gradient to remove
  50325. * @returns the current particle system
  50326. */
  50327. removeAlphaRemapGradient(): IParticleSystem;
  50328. /**
  50329. * Not supported by GPUParticleSystem
  50330. * @param gradient defines the gradient to use (between 0 and 1)
  50331. * @param color defines the color to affect to the specified gradient
  50332. * @returns the current particle system
  50333. */
  50334. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50335. /**
  50336. * Not supported by GPUParticleSystem
  50337. * @param gradient defines the gradient to remove
  50338. * @returns the current particle system
  50339. */
  50340. removeRampGradient(): IParticleSystem;
  50341. /**
  50342. * Not supported by GPUParticleSystem
  50343. * @returns the list of ramp gradients
  50344. */
  50345. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50346. /**
  50347. * Not supported by GPUParticleSystem
  50348. * Gets or sets a boolean indicating that ramp gradients must be used
  50349. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50350. */
  50351. useRampGradients: boolean;
  50352. /**
  50353. * Not supported by GPUParticleSystem
  50354. * @param gradient defines the gradient to use (between 0 and 1)
  50355. * @param factor defines the life time factor to affect to the specified gradient
  50356. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50357. * @returns the current particle system
  50358. */
  50359. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50360. /**
  50361. * Not supported by GPUParticleSystem
  50362. * @param gradient defines the gradient to remove
  50363. * @returns the current particle system
  50364. */
  50365. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50366. /**
  50367. * Instantiates a GPU particle system.
  50368. * 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.
  50369. * @param name The name of the particle system
  50370. * @param options The options used to create the system
  50371. * @param scene The scene the particle system belongs to
  50372. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50373. */
  50374. constructor(name: string, options: Partial<{
  50375. capacity: number;
  50376. randomTextureSize: number;
  50377. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50378. protected _reset(): void;
  50379. private _createUpdateVAO;
  50380. private _createRenderVAO;
  50381. private _initialize;
  50382. /** @hidden */ recreateUpdateEffect(): void;
  50383. /** @hidden */ recreateRenderEffect(): void;
  50384. /**
  50385. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50386. * @param preWarm defines if we are in the pre-warmimg phase
  50387. */
  50388. animate(preWarm?: boolean): void;
  50389. private _createFactorGradientTexture;
  50390. private _createSizeGradientTexture;
  50391. private _createAngularSpeedGradientTexture;
  50392. private _createVelocityGradientTexture;
  50393. private _createLimitVelocityGradientTexture;
  50394. private _createDragGradientTexture;
  50395. private _createColorGradientTexture;
  50396. /**
  50397. * Renders the particle system in its current state
  50398. * @param preWarm defines if the system should only update the particles but not render them
  50399. * @returns the current number of particles
  50400. */
  50401. render(preWarm?: boolean): number;
  50402. /**
  50403. * Rebuilds the particle system
  50404. */
  50405. rebuild(): void;
  50406. private _releaseBuffers;
  50407. private _releaseVAOs;
  50408. /**
  50409. * Disposes the particle system and free the associated resources
  50410. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50411. */
  50412. dispose(disposeTexture?: boolean): void;
  50413. /**
  50414. * Clones the particle system.
  50415. * @param name The name of the cloned object
  50416. * @param newEmitter The new emitter to use
  50417. * @returns the cloned particle system
  50418. */
  50419. clone(name: string, newEmitter: any): GPUParticleSystem;
  50420. /**
  50421. * Serializes the particle system to a JSON object.
  50422. * @returns the JSON object
  50423. */
  50424. serialize(): any;
  50425. /**
  50426. * Parses a JSON object to create a GPU particle system.
  50427. * @param parsedParticleSystem The JSON object to parse
  50428. * @param scene The scene to create the particle system in
  50429. * @param rootUrl The root url to use to load external dependencies like texture
  50430. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50431. * @returns the parsed GPU particle system
  50432. */
  50433. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50434. }
  50435. }
  50436. declare module BABYLON {
  50437. /**
  50438. * Represents a set of particle systems working together to create a specific effect
  50439. */
  50440. export class ParticleSystemSet implements IDisposable {
  50441. private _emitterCreationOptions;
  50442. private _emitterNode;
  50443. /**
  50444. * Gets the particle system list
  50445. */
  50446. systems: IParticleSystem[];
  50447. /**
  50448. * Gets the emitter node used with this set
  50449. */
  50450. readonly emitterNode: Nullable<TransformNode>;
  50451. /**
  50452. * Creates a new emitter mesh as a sphere
  50453. * @param options defines the options used to create the sphere
  50454. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50455. * @param scene defines the hosting scene
  50456. */
  50457. setEmitterAsSphere(options: {
  50458. diameter: number;
  50459. segments: number;
  50460. color: Color3;
  50461. }, renderingGroupId: number, scene: Scene): void;
  50462. /**
  50463. * Starts all particle systems of the set
  50464. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50465. */
  50466. start(emitter?: AbstractMesh): void;
  50467. /**
  50468. * Release all associated resources
  50469. */
  50470. dispose(): void;
  50471. /**
  50472. * Serialize the set into a JSON compatible object
  50473. * @returns a JSON compatible representation of the set
  50474. */
  50475. serialize(): any;
  50476. /**
  50477. * Parse a new ParticleSystemSet from a serialized source
  50478. * @param data defines a JSON compatible representation of the set
  50479. * @param scene defines the hosting scene
  50480. * @param gpu defines if we want GPU particles or CPU particles
  50481. * @returns a new ParticleSystemSet
  50482. */
  50483. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50484. }
  50485. }
  50486. declare module BABYLON {
  50487. /**
  50488. * This class is made for on one-liner static method to help creating particle system set.
  50489. */
  50490. export class ParticleHelper {
  50491. /**
  50492. * Gets or sets base Assets URL
  50493. */
  50494. static BaseAssetsUrl: string;
  50495. /**
  50496. * Create a default particle system that you can tweak
  50497. * @param emitter defines the emitter to use
  50498. * @param capacity defines the system capacity (default is 500 particles)
  50499. * @param scene defines the hosting scene
  50500. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50501. * @returns the new Particle system
  50502. */
  50503. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50504. /**
  50505. * This is the main static method (one-liner) of this helper to create different particle systems
  50506. * @param type This string represents the type to the particle system to create
  50507. * @param scene The scene where the particle system should live
  50508. * @param gpu If the system will use gpu
  50509. * @returns the ParticleSystemSet created
  50510. */
  50511. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50512. /**
  50513. * Static function used to export a particle system to a ParticleSystemSet variable.
  50514. * Please note that the emitter shape is not exported
  50515. * @param systems defines the particle systems to export
  50516. * @returns the created particle system set
  50517. */
  50518. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50519. }
  50520. }
  50521. declare module BABYLON {
  50522. interface Engine {
  50523. /**
  50524. * Create an effect to use with particle systems.
  50525. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50526. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50527. * @param uniformsNames defines a list of attribute names
  50528. * @param samplers defines an array of string used to represent textures
  50529. * @param defines defines the string containing the defines to use to compile the shaders
  50530. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50531. * @param onCompiled defines a function to call when the effect creation is successful
  50532. * @param onError defines a function to call when the effect creation has failed
  50533. * @returns the new Effect
  50534. */
  50535. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50536. }
  50537. interface Mesh {
  50538. /**
  50539. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50540. * @returns an array of IParticleSystem
  50541. */
  50542. getEmittedParticleSystems(): IParticleSystem[];
  50543. /**
  50544. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50545. * @returns an array of IParticleSystem
  50546. */
  50547. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50548. }
  50549. /**
  50550. * @hidden
  50551. */
  50552. export var _IDoNeedToBeInTheBuild: number;
  50553. }
  50554. declare module BABYLON {
  50555. interface Scene {
  50556. /** @hidden (Backing field) */ physicsEngine: Nullable<IPhysicsEngine>;
  50557. /**
  50558. * Gets the current physics engine
  50559. * @returns a IPhysicsEngine or null if none attached
  50560. */
  50561. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  50562. /**
  50563. * Enables physics to the current scene
  50564. * @param gravity defines the scene's gravity for the physics engine
  50565. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  50566. * @return a boolean indicating if the physics engine was initialized
  50567. */
  50568. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  50569. /**
  50570. * Disables and disposes the physics engine associated with the scene
  50571. */
  50572. disablePhysicsEngine(): void;
  50573. /**
  50574. * Gets a boolean indicating if there is an active physics engine
  50575. * @returns a boolean indicating if there is an active physics engine
  50576. */
  50577. isPhysicsEnabled(): boolean;
  50578. /**
  50579. * Deletes a physics compound impostor
  50580. * @param compound defines the compound to delete
  50581. */
  50582. deleteCompoundImpostor(compound: any): void;
  50583. /**
  50584. * An event triggered when physic simulation is about to be run
  50585. */
  50586. onBeforePhysicsObservable: Observable<Scene>;
  50587. /**
  50588. * An event triggered when physic simulation has been done
  50589. */
  50590. onAfterPhysicsObservable: Observable<Scene>;
  50591. }
  50592. interface AbstractMesh {
  50593. /** @hidden */ physicsImpostor: Nullable<PhysicsImpostor>;
  50594. /**
  50595. * Gets or sets impostor used for physic simulation
  50596. * @see http://doc.babylonjs.com/features/physics_engine
  50597. */
  50598. physicsImpostor: Nullable<PhysicsImpostor>;
  50599. /**
  50600. * Gets the current physics impostor
  50601. * @see http://doc.babylonjs.com/features/physics_engine
  50602. * @returns a physics impostor or null
  50603. */
  50604. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  50605. /** Apply a physic impulse to the mesh
  50606. * @param force defines the force to apply
  50607. * @param contactPoint defines where to apply the force
  50608. * @returns the current mesh
  50609. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50610. */
  50611. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  50612. /**
  50613. * Creates a physic joint between two meshes
  50614. * @param otherMesh defines the other mesh to use
  50615. * @param pivot1 defines the pivot to use on this mesh
  50616. * @param pivot2 defines the pivot to use on the other mesh
  50617. * @param options defines additional options (can be plugin dependent)
  50618. * @returns the current mesh
  50619. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  50620. */
  50621. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  50622. /** @hidden */ disposePhysicsObserver: Nullable<Observer<Node>>;
  50623. }
  50624. /**
  50625. * Defines the physics engine scene component responsible to manage a physics engine
  50626. */
  50627. export class PhysicsEngineSceneComponent implements ISceneComponent {
  50628. /**
  50629. * The component name helpful to identify the component in the list of scene components.
  50630. */
  50631. readonly name: string;
  50632. /**
  50633. * The scene the component belongs to.
  50634. */
  50635. scene: Scene;
  50636. /**
  50637. * Creates a new instance of the component for the given scene
  50638. * @param scene Defines the scene to register the component in
  50639. */
  50640. constructor(scene: Scene);
  50641. /**
  50642. * Registers the component in a given scene
  50643. */
  50644. register(): void;
  50645. /**
  50646. * Rebuilds the elements related to this component in case of
  50647. * context lost for instance.
  50648. */
  50649. rebuild(): void;
  50650. /**
  50651. * Disposes the component and the associated ressources
  50652. */
  50653. dispose(): void;
  50654. }
  50655. }
  50656. declare module BABYLON {
  50657. /**
  50658. * A helper for physics simulations
  50659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50660. */
  50661. export class PhysicsHelper {
  50662. private _scene;
  50663. private _physicsEngine;
  50664. /**
  50665. * Initializes the Physics helper
  50666. * @param scene Babylon.js scene
  50667. */
  50668. constructor(scene: Scene);
  50669. /**
  50670. * Applies a radial explosion impulse
  50671. * @param origin the origin of the explosion
  50672. * @param radiusOrEventOptions the radius or the options of radial explosion
  50673. * @param strength the explosion strength
  50674. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50675. * @returns A physics radial explosion event, or null
  50676. */
  50677. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50678. /**
  50679. * Applies a radial explosion force
  50680. * @param origin the origin of the explosion
  50681. * @param radiusOrEventOptions the radius or the options of radial explosion
  50682. * @param strength the explosion strength
  50683. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50684. * @returns A physics radial explosion event, or null
  50685. */
  50686. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50687. /**
  50688. * Creates a gravitational field
  50689. * @param origin the origin of the explosion
  50690. * @param radiusOrEventOptions the radius or the options of radial explosion
  50691. * @param strength the explosion strength
  50692. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50693. * @returns A physics gravitational field event, or null
  50694. */
  50695. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  50696. /**
  50697. * Creates a physics updraft event
  50698. * @param origin the origin of the updraft
  50699. * @param radiusOrEventOptions the radius or the options of the updraft
  50700. * @param strength the strength of the updraft
  50701. * @param height the height of the updraft
  50702. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  50703. * @returns A physics updraft event, or null
  50704. */
  50705. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  50706. /**
  50707. * Creates a physics vortex event
  50708. * @param origin the of the vortex
  50709. * @param radiusOrEventOptions the radius or the options of the vortex
  50710. * @param strength the strength of the vortex
  50711. * @param height the height of the vortex
  50712. * @returns a Physics vortex event, or null
  50713. * A physics vortex event or null
  50714. */
  50715. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  50716. }
  50717. /**
  50718. * Represents a physics radial explosion event
  50719. */
  50720. class PhysicsRadialExplosionEvent {
  50721. private _scene;
  50722. private _options;
  50723. private _sphere;
  50724. private _dataFetched;
  50725. /**
  50726. * Initializes a radial explosioin event
  50727. * @param _scene BabylonJS scene
  50728. * @param _options The options for the vortex event
  50729. */
  50730. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  50731. /**
  50732. * Returns the data related to the radial explosion event (sphere).
  50733. * @returns The radial explosion event data
  50734. */
  50735. getData(): PhysicsRadialExplosionEventData;
  50736. /**
  50737. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  50738. * @param impostor A physics imposter
  50739. * @param origin the origin of the explosion
  50740. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  50741. */
  50742. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  50743. /**
  50744. * Triggers affecterd impostors callbacks
  50745. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  50746. */
  50747. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  50748. /**
  50749. * Disposes the sphere.
  50750. * @param force Specifies if the sphere should be disposed by force
  50751. */
  50752. dispose(force?: boolean): void;
  50753. /*** Helpers ***/
  50754. private _prepareSphere;
  50755. private _intersectsWithSphere;
  50756. }
  50757. /**
  50758. * Represents a gravitational field event
  50759. */
  50760. class PhysicsGravitationalFieldEvent {
  50761. private _physicsHelper;
  50762. private _scene;
  50763. private _origin;
  50764. private _options;
  50765. private _tickCallback;
  50766. private _sphere;
  50767. private _dataFetched;
  50768. /**
  50769. * Initializes the physics gravitational field event
  50770. * @param _physicsHelper A physics helper
  50771. * @param _scene BabylonJS scene
  50772. * @param _origin The origin position of the gravitational field event
  50773. * @param _options The options for the vortex event
  50774. */
  50775. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  50776. /**
  50777. * Returns the data related to the gravitational field event (sphere).
  50778. * @returns A gravitational field event
  50779. */
  50780. getData(): PhysicsGravitationalFieldEventData;
  50781. /**
  50782. * Enables the gravitational field.
  50783. */
  50784. enable(): void;
  50785. /**
  50786. * Disables the gravitational field.
  50787. */
  50788. disable(): void;
  50789. /**
  50790. * Disposes the sphere.
  50791. * @param force The force to dispose from the gravitational field event
  50792. */
  50793. dispose(force?: boolean): void;
  50794. private _tick;
  50795. }
  50796. /**
  50797. * Represents a physics updraft event
  50798. */
  50799. class PhysicsUpdraftEvent {
  50800. private _scene;
  50801. private _origin;
  50802. private _options;
  50803. private _physicsEngine;
  50804. private _originTop;
  50805. private _originDirection;
  50806. private _tickCallback;
  50807. private _cylinder;
  50808. private _cylinderPosition;
  50809. private _dataFetched;
  50810. /**
  50811. * Initializes the physics updraft event
  50812. * @param _scene BabylonJS scene
  50813. * @param _origin The origin position of the updraft
  50814. * @param _options The options for the updraft event
  50815. */
  50816. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  50817. /**
  50818. * Returns the data related to the updraft event (cylinder).
  50819. * @returns A physics updraft event
  50820. */
  50821. getData(): PhysicsUpdraftEventData;
  50822. /**
  50823. * Enables the updraft.
  50824. */
  50825. enable(): void;
  50826. /**
  50827. * Disables the updraft.
  50828. */
  50829. disable(): void;
  50830. /**
  50831. * Disposes the cylinder.
  50832. * @param force Specifies if the updraft should be disposed by force
  50833. */
  50834. dispose(force?: boolean): void;
  50835. private getImpostorHitData;
  50836. private _tick;
  50837. /*** Helpers ***/
  50838. private _prepareCylinder;
  50839. private _intersectsWithCylinder;
  50840. }
  50841. /**
  50842. * Represents a physics vortex event
  50843. */
  50844. class PhysicsVortexEvent {
  50845. private _scene;
  50846. private _origin;
  50847. private _options;
  50848. private _physicsEngine;
  50849. private _originTop;
  50850. private _tickCallback;
  50851. private _cylinder;
  50852. private _cylinderPosition;
  50853. private _dataFetched;
  50854. /**
  50855. * Initializes the physics vortex event
  50856. * @param _scene The BabylonJS scene
  50857. * @param _origin The origin position of the vortex
  50858. * @param _options The options for the vortex event
  50859. */
  50860. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  50861. /**
  50862. * Returns the data related to the vortex event (cylinder).
  50863. * @returns The physics vortex event data
  50864. */
  50865. getData(): PhysicsVortexEventData;
  50866. /**
  50867. * Enables the vortex.
  50868. */
  50869. enable(): void;
  50870. /**
  50871. * Disables the cortex.
  50872. */
  50873. disable(): void;
  50874. /**
  50875. * Disposes the sphere.
  50876. * @param force
  50877. */
  50878. dispose(force?: boolean): void;
  50879. private getImpostorHitData;
  50880. private _tick;
  50881. /*** Helpers ***/
  50882. private _prepareCylinder;
  50883. private _intersectsWithCylinder;
  50884. }
  50885. /**
  50886. * Options fot the radial explosion event
  50887. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50888. */
  50889. export class PhysicsRadialExplosionEventOptions {
  50890. /**
  50891. * The radius of the sphere for the radial explosion.
  50892. */
  50893. radius: number;
  50894. /**
  50895. * The strenth of the explosion.
  50896. */
  50897. strength: number;
  50898. /**
  50899. * The strenght of the force in correspondence to the distance of the affected object
  50900. */
  50901. falloff: PhysicsRadialImpulseFalloff;
  50902. /**
  50903. * Sphere options for the radial explosion.
  50904. */
  50905. sphere: {
  50906. segments: number;
  50907. diameter: number;
  50908. };
  50909. /**
  50910. * Sphere options for the radial explosion.
  50911. */
  50912. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  50913. }
  50914. /**
  50915. * Options fot the updraft event
  50916. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50917. */
  50918. export class PhysicsUpdraftEventOptions {
  50919. /**
  50920. * The radius of the cylinder for the vortex
  50921. */
  50922. radius: number;
  50923. /**
  50924. * The strenth of the updraft.
  50925. */
  50926. strength: number;
  50927. /**
  50928. * The height of the cylinder for the updraft.
  50929. */
  50930. height: number;
  50931. /**
  50932. * The mode for the the updraft.
  50933. */
  50934. updraftMode: PhysicsUpdraftMode;
  50935. }
  50936. /**
  50937. * Options fot the vortex event
  50938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50939. */
  50940. export class PhysicsVortexEventOptions {
  50941. /**
  50942. * The radius of the cylinder for the vortex
  50943. */
  50944. radius: number;
  50945. /**
  50946. * The strenth of the vortex.
  50947. */
  50948. strength: number;
  50949. /**
  50950. * The height of the cylinder for the vortex.
  50951. */
  50952. height: number;
  50953. /**
  50954. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  50955. */
  50956. centripetalForceThreshold: number;
  50957. /**
  50958. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  50959. */
  50960. centripetalForceMultiplier: number;
  50961. /**
  50962. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  50963. */
  50964. centrifugalForceMultiplier: number;
  50965. /**
  50966. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  50967. */
  50968. updraftForceMultiplier: number;
  50969. }
  50970. /**
  50971. * The strenght of the force in correspondence to the distance of the affected object
  50972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50973. */
  50974. export enum PhysicsRadialImpulseFalloff {
  50975. /** Defines that impulse is constant in strength across it's whole radius */
  50976. Constant = 0,
  50977. /** Defines that impulse gets weaker if it's further from the origin */
  50978. Linear = 1
  50979. }
  50980. /**
  50981. * The strength of the force in correspondence to the distance of the affected object
  50982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50983. */
  50984. export enum PhysicsUpdraftMode {
  50985. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  50986. Center = 0,
  50987. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  50988. Perpendicular = 1
  50989. }
  50990. /**
  50991. * Interface for a physics hit data
  50992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50993. */
  50994. export interface PhysicsHitData {
  50995. /**
  50996. * The force applied at the contact point
  50997. */
  50998. force: Vector3;
  50999. /**
  51000. * The contact point
  51001. */
  51002. contactPoint: Vector3;
  51003. /**
  51004. * The distance from the origin to the contact point
  51005. */
  51006. distanceFromOrigin: number;
  51007. }
  51008. /**
  51009. * Interface for radial explosion event data
  51010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51011. */
  51012. export interface PhysicsRadialExplosionEventData {
  51013. /**
  51014. * A sphere used for the radial explosion event
  51015. */
  51016. sphere: Mesh;
  51017. }
  51018. /**
  51019. * Interface for gravitational field event data
  51020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51021. */
  51022. export interface PhysicsGravitationalFieldEventData {
  51023. /**
  51024. * A sphere mesh used for the gravitational field event
  51025. */
  51026. sphere: Mesh;
  51027. }
  51028. /**
  51029. * Interface for updraft event data
  51030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51031. */
  51032. export interface PhysicsUpdraftEventData {
  51033. /**
  51034. * A cylinder used for the updraft event
  51035. */
  51036. cylinder: Mesh;
  51037. }
  51038. /**
  51039. * Interface for vortex event data
  51040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51041. */
  51042. export interface PhysicsVortexEventData {
  51043. /**
  51044. * A cylinder used for the vortex event
  51045. */
  51046. cylinder: Mesh;
  51047. }
  51048. /**
  51049. * Interface for an affected physics impostor
  51050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51051. */
  51052. export interface PhysicsAffectedImpostorWithData {
  51053. /**
  51054. * The impostor affected by the effect
  51055. */
  51056. impostor: PhysicsImpostor;
  51057. /**
  51058. * The data about the hit/horce from the explosion
  51059. */
  51060. hitData: PhysicsHitData;
  51061. }
  51062. }
  51063. declare module BABYLON {
  51064. /** @hidden */
  51065. export var blackAndWhitePixelShader: {
  51066. name: string;
  51067. shader: string;
  51068. };
  51069. }
  51070. declare module BABYLON {
  51071. /**
  51072. * Post process used to render in black and white
  51073. */
  51074. export class BlackAndWhitePostProcess extends PostProcess {
  51075. /**
  51076. * Linear about to convert he result to black and white (default: 1)
  51077. */
  51078. degree: number;
  51079. /**
  51080. * Creates a black and white post process
  51081. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51082. * @param name The name of the effect.
  51083. * @param options The required width/height ratio to downsize to before computing the render pass.
  51084. * @param camera The camera to apply the render pass to.
  51085. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51086. * @param engine The engine which the post process will be applied. (default: current engine)
  51087. * @param reusable If the post process can be reused on the same frame. (default: false)
  51088. */
  51089. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51090. }
  51091. }
  51092. declare module BABYLON {
  51093. /**
  51094. * This represents a set of one or more post processes in Babylon.
  51095. * A post process can be used to apply a shader to a texture after it is rendered.
  51096. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51097. */
  51098. export class PostProcessRenderEffect {
  51099. private _postProcesses;
  51100. private _getPostProcesses;
  51101. private _singleInstance;
  51102. private _cameras;
  51103. private _indicesForCamera;
  51104. /**
  51105. * Name of the effect
  51106. * @hidden
  51107. */ name: string;
  51108. /**
  51109. * Instantiates a post process render effect.
  51110. * A post process can be used to apply a shader to a texture after it is rendered.
  51111. * @param engine The engine the effect is tied to
  51112. * @param name The name of the effect
  51113. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51114. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51115. */
  51116. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51117. /**
  51118. * Checks if all the post processes in the effect are supported.
  51119. */
  51120. readonly isSupported: boolean;
  51121. /**
  51122. * Updates the current state of the effect
  51123. * @hidden
  51124. */ update(): void;
  51125. /**
  51126. * Attaches the effect on cameras
  51127. * @param cameras The camera to attach to.
  51128. * @hidden
  51129. */ attachCameras(cameras: Camera): void;
  51130. /**
  51131. * Attaches the effect on cameras
  51132. * @param cameras The camera to attach to.
  51133. * @hidden
  51134. */ attachCameras(cameras: Camera[]): void;
  51135. /**
  51136. * Detatches the effect on cameras
  51137. * @param cameras The camera to detatch from.
  51138. * @hidden
  51139. */ detachCameras(cameras: Camera): void;
  51140. /**
  51141. * Detatches the effect on cameras
  51142. * @param cameras The camera to detatch from.
  51143. * @hidden
  51144. */ detachCameras(cameras: Camera[]): void;
  51145. /**
  51146. * Enables the effect on given cameras
  51147. * @param cameras The camera to enable.
  51148. * @hidden
  51149. */ enable(cameras: Camera): void;
  51150. /**
  51151. * Enables the effect on given cameras
  51152. * @param cameras The camera to enable.
  51153. * @hidden
  51154. */ enable(cameras: Nullable<Camera[]>): void;
  51155. /**
  51156. * Disables the effect on the given cameras
  51157. * @param cameras The camera to disable.
  51158. * @hidden
  51159. */ disable(cameras: Camera): void;
  51160. /**
  51161. * Disables the effect on the given cameras
  51162. * @param cameras The camera to disable.
  51163. * @hidden
  51164. */ disable(cameras: Nullable<Camera[]>): void;
  51165. /**
  51166. * Gets a list of the post processes contained in the effect.
  51167. * @param camera The camera to get the post processes on.
  51168. * @returns The list of the post processes in the effect.
  51169. */
  51170. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51171. }
  51172. }
  51173. declare module BABYLON {
  51174. /** @hidden */
  51175. export var extractHighlightsPixelShader: {
  51176. name: string;
  51177. shader: string;
  51178. };
  51179. }
  51180. declare module BABYLON {
  51181. /**
  51182. * 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.
  51183. */
  51184. export class ExtractHighlightsPostProcess extends PostProcess {
  51185. /**
  51186. * The luminance threshold, pixels below this value will be set to black.
  51187. */
  51188. threshold: number;
  51189. /** @hidden */ exposure: number;
  51190. /**
  51191. * Post process which has the input texture to be used when performing highlight extraction
  51192. * @hidden
  51193. */ inputPostProcess: Nullable<PostProcess>;
  51194. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51195. }
  51196. }
  51197. declare module BABYLON {
  51198. /** @hidden */
  51199. export var bloomMergePixelShader: {
  51200. name: string;
  51201. shader: string;
  51202. };
  51203. }
  51204. declare module BABYLON {
  51205. /**
  51206. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51207. */
  51208. export class BloomMergePostProcess extends PostProcess {
  51209. /** Weight of the bloom to be added to the original input. */
  51210. weight: number;
  51211. /**
  51212. * Creates a new instance of @see BloomMergePostProcess
  51213. * @param name The name of the effect.
  51214. * @param originalFromInput Post process which's input will be used for the merge.
  51215. * @param blurred Blurred highlights post process which's output will be used.
  51216. * @param weight Weight of the bloom to be added to the original input.
  51217. * @param options The required width/height ratio to downsize to before computing the render pass.
  51218. * @param camera The camera to apply the render pass to.
  51219. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51220. * @param engine The engine which the post process will be applied. (default: current engine)
  51221. * @param reusable If the post process can be reused on the same frame. (default: false)
  51222. * @param textureType Type of textures used when performing the post process. (default: 0)
  51223. * @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)
  51224. */
  51225. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51226. /** Weight of the bloom to be added to the original input. */
  51227. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51228. }
  51229. }
  51230. declare module BABYLON {
  51231. /**
  51232. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51233. */
  51234. export class BloomEffect extends PostProcessRenderEffect {
  51235. private bloomScale;
  51236. /**
  51237. * @hidden Internal
  51238. */ effects: Array<PostProcess>;
  51239. /**
  51240. * @hidden Internal
  51241. */ downscale: ExtractHighlightsPostProcess;
  51242. private _blurX;
  51243. private _blurY;
  51244. private _merge;
  51245. /**
  51246. * The luminance threshold to find bright areas of the image to bloom.
  51247. */
  51248. threshold: number;
  51249. /**
  51250. * The strength of the bloom.
  51251. */
  51252. weight: number;
  51253. /**
  51254. * Specifies the size of the bloom blur kernel, relative to the final output size
  51255. */
  51256. kernel: number;
  51257. /**
  51258. * Creates a new instance of @see BloomEffect
  51259. * @param scene The scene the effect belongs to.
  51260. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51261. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51262. * @param bloomWeight The the strength of bloom.
  51263. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51264. * @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)
  51265. */
  51266. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51267. /**
  51268. * Disposes each of the internal effects for a given camera.
  51269. * @param camera The camera to dispose the effect on.
  51270. */
  51271. disposeEffects(camera: Camera): void;
  51272. /**
  51273. * @hidden Internal
  51274. */ updateEffects(): void;
  51275. /**
  51276. * Internal
  51277. * @returns if all the contained post processes are ready.
  51278. * @hidden
  51279. */ isReady(): boolean;
  51280. }
  51281. }
  51282. declare module BABYLON {
  51283. /** @hidden */
  51284. export var chromaticAberrationPixelShader: {
  51285. name: string;
  51286. shader: string;
  51287. };
  51288. }
  51289. declare module BABYLON {
  51290. /**
  51291. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51292. */
  51293. export class ChromaticAberrationPostProcess extends PostProcess {
  51294. /**
  51295. * The amount of seperation of rgb channels (default: 30)
  51296. */
  51297. aberrationAmount: number;
  51298. /**
  51299. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51300. */
  51301. radialIntensity: number;
  51302. /**
  51303. * 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))
  51304. */
  51305. direction: Vector2;
  51306. /**
  51307. * 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))
  51308. */
  51309. centerPosition: Vector2;
  51310. /**
  51311. * Creates a new instance ChromaticAberrationPostProcess
  51312. * @param name The name of the effect.
  51313. * @param screenWidth The width of the screen to apply the effect on.
  51314. * @param screenHeight The height of the screen to apply the effect on.
  51315. * @param options The required width/height ratio to downsize to before computing the render pass.
  51316. * @param camera The camera to apply the render pass to.
  51317. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51318. * @param engine The engine which the post process will be applied. (default: current engine)
  51319. * @param reusable If the post process can be reused on the same frame. (default: false)
  51320. * @param textureType Type of textures used when performing the post process. (default: 0)
  51321. * @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)
  51322. */
  51323. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51324. }
  51325. }
  51326. declare module BABYLON {
  51327. /** @hidden */
  51328. export var circleOfConfusionPixelShader: {
  51329. name: string;
  51330. shader: string;
  51331. };
  51332. }
  51333. declare module BABYLON {
  51334. /**
  51335. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51336. */
  51337. export class CircleOfConfusionPostProcess extends PostProcess {
  51338. /**
  51339. * 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.
  51340. */
  51341. lensSize: number;
  51342. /**
  51343. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51344. */
  51345. fStop: number;
  51346. /**
  51347. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51348. */
  51349. focusDistance: number;
  51350. /**
  51351. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51352. */
  51353. focalLength: number;
  51354. private _depthTexture;
  51355. /**
  51356. * Creates a new instance CircleOfConfusionPostProcess
  51357. * @param name The name of the effect.
  51358. * @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.
  51359. * @param options The required width/height ratio to downsize to before computing the render pass.
  51360. * @param camera The camera to apply the render pass to.
  51361. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51362. * @param engine The engine which the post process will be applied. (default: current engine)
  51363. * @param reusable If the post process can be reused on the same frame. (default: false)
  51364. * @param textureType Type of textures used when performing the post process. (default: 0)
  51365. * @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)
  51366. */
  51367. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51368. /**
  51369. * 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.
  51370. */
  51371. depthTexture: RenderTargetTexture;
  51372. }
  51373. }
  51374. declare module BABYLON {
  51375. /** @hidden */
  51376. export var colorCorrectionPixelShader: {
  51377. name: string;
  51378. shader: string;
  51379. };
  51380. }
  51381. declare module BABYLON {
  51382. /**
  51383. *
  51384. * This post-process allows the modification of rendered colors by using
  51385. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51386. *
  51387. * The object needs to be provided an url to a texture containing the color
  51388. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51389. * Use an image editing software to tweak the LUT to match your needs.
  51390. *
  51391. * For an example of a color LUT, see here:
  51392. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51393. * For explanations on color grading, see here:
  51394. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51395. *
  51396. */
  51397. export class ColorCorrectionPostProcess extends PostProcess {
  51398. private _colorTableTexture;
  51399. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51400. }
  51401. }
  51402. declare module BABYLON {
  51403. /** @hidden */
  51404. export var convolutionPixelShader: {
  51405. name: string;
  51406. shader: string;
  51407. };
  51408. }
  51409. declare module BABYLON {
  51410. /**
  51411. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51412. * input texture to perform effects such as edge detection or sharpening
  51413. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51414. */
  51415. export class ConvolutionPostProcess extends PostProcess {
  51416. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51417. kernel: number[];
  51418. /**
  51419. * Creates a new instance ConvolutionPostProcess
  51420. * @param name The name of the effect.
  51421. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51422. * @param options The required width/height ratio to downsize to before computing the render pass.
  51423. * @param camera The camera to apply the render pass to.
  51424. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51425. * @param engine The engine which the post process will be applied. (default: current engine)
  51426. * @param reusable If the post process can be reused on the same frame. (default: false)
  51427. * @param textureType Type of textures used when performing the post process. (default: 0)
  51428. */
  51429. constructor(name: string,
  51430. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51431. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51432. /**
  51433. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51434. */
  51435. static EdgeDetect0Kernel: number[];
  51436. /**
  51437. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51438. */
  51439. static EdgeDetect1Kernel: number[];
  51440. /**
  51441. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51442. */
  51443. static EdgeDetect2Kernel: number[];
  51444. /**
  51445. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51446. */
  51447. static SharpenKernel: number[];
  51448. /**
  51449. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51450. */
  51451. static EmbossKernel: number[];
  51452. /**
  51453. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51454. */
  51455. static GaussianKernel: number[];
  51456. }
  51457. }
  51458. declare module BABYLON {
  51459. /**
  51460. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51461. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51462. * based on samples that have a large difference in distance than the center pixel.
  51463. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51464. */
  51465. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51466. direction: Vector2;
  51467. /**
  51468. * Creates a new instance CircleOfConfusionPostProcess
  51469. * @param name The name of the effect.
  51470. * @param scene The scene the effect belongs to.
  51471. * @param direction The direction the blur should be applied.
  51472. * @param kernel The size of the kernel used to blur.
  51473. * @param options The required width/height ratio to downsize to before computing the render pass.
  51474. * @param camera The camera to apply the render pass to.
  51475. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51476. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51478. * @param engine The engine which the post process will be applied. (default: current engine)
  51479. * @param reusable If the post process can be reused on the same frame. (default: false)
  51480. * @param textureType Type of textures used when performing the post process. (default: 0)
  51481. * @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)
  51482. */
  51483. 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);
  51484. }
  51485. }
  51486. declare module BABYLON {
  51487. /** @hidden */
  51488. export var depthOfFieldMergePixelShader: {
  51489. name: string;
  51490. shader: string;
  51491. };
  51492. }
  51493. declare module BABYLON {
  51494. /**
  51495. * Options to be set when merging outputs from the default pipeline.
  51496. */
  51497. export class DepthOfFieldMergePostProcessOptions {
  51498. /**
  51499. * The original image to merge on top of
  51500. */
  51501. originalFromInput: PostProcess;
  51502. /**
  51503. * Parameters to perform the merge of the depth of field effect
  51504. */
  51505. depthOfField?: {
  51506. circleOfConfusion: PostProcess;
  51507. blurSteps: Array<PostProcess>;
  51508. };
  51509. /**
  51510. * Parameters to perform the merge of bloom effect
  51511. */
  51512. bloom?: {
  51513. blurred: PostProcess;
  51514. weight: number;
  51515. };
  51516. }
  51517. /**
  51518. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51519. */
  51520. export class DepthOfFieldMergePostProcess extends PostProcess {
  51521. private blurSteps;
  51522. /**
  51523. * Creates a new instance of DepthOfFieldMergePostProcess
  51524. * @param name The name of the effect.
  51525. * @param originalFromInput Post process which's input will be used for the merge.
  51526. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51527. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51528. * @param options The required width/height ratio to downsize to before computing the render pass.
  51529. * @param camera The camera to apply the render pass to.
  51530. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51531. * @param engine The engine which the post process will be applied. (default: current engine)
  51532. * @param reusable If the post process can be reused on the same frame. (default: false)
  51533. * @param textureType Type of textures used when performing the post process. (default: 0)
  51534. * @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)
  51535. */
  51536. 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);
  51537. /**
  51538. * Updates the effect with the current post process compile time values and recompiles the shader.
  51539. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  51540. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  51541. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  51542. * @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
  51543. * @param onCompiled Called when the shader has been compiled.
  51544. * @param onError Called if there is an error when compiling a shader.
  51545. */
  51546. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  51547. }
  51548. }
  51549. declare module BABYLON {
  51550. /**
  51551. * Specifies the level of max blur that should be applied when using the depth of field effect
  51552. */
  51553. export enum DepthOfFieldEffectBlurLevel {
  51554. /**
  51555. * Subtle blur
  51556. */
  51557. Low = 0,
  51558. /**
  51559. * Medium blur
  51560. */
  51561. Medium = 1,
  51562. /**
  51563. * Large blur
  51564. */
  51565. High = 2
  51566. }
  51567. /**
  51568. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  51569. */
  51570. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  51571. private _circleOfConfusion;
  51572. /**
  51573. * @hidden Internal, blurs from high to low
  51574. */ depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  51575. private _depthOfFieldBlurY;
  51576. private _dofMerge;
  51577. /**
  51578. * @hidden Internal post processes in depth of field effect
  51579. */ effects: Array<PostProcess>;
  51580. /**
  51581. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  51582. */
  51583. focalLength: number;
  51584. /**
  51585. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51586. */
  51587. fStop: number;
  51588. /**
  51589. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51590. */
  51591. focusDistance: number;
  51592. /**
  51593. * 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.
  51594. */
  51595. lensSize: number;
  51596. /**
  51597. * Creates a new instance DepthOfFieldEffect
  51598. * @param scene The scene the effect belongs to.
  51599. * @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.
  51600. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51601. * @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)
  51602. */
  51603. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  51604. /**
  51605. * 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.
  51606. */
  51607. depthTexture: RenderTargetTexture;
  51608. /**
  51609. * Disposes each of the internal effects for a given camera.
  51610. * @param camera The camera to dispose the effect on.
  51611. */
  51612. disposeEffects(camera: Camera): void;
  51613. /**
  51614. * @hidden Internal
  51615. */ updateEffects(): void;
  51616. /**
  51617. * Internal
  51618. * @returns if all the contained post processes are ready.
  51619. * @hidden
  51620. */ isReady(): boolean;
  51621. }
  51622. }
  51623. declare module BABYLON {
  51624. /** @hidden */
  51625. export var displayPassPixelShader: {
  51626. name: string;
  51627. shader: string;
  51628. };
  51629. }
  51630. declare module BABYLON {
  51631. /**
  51632. * DisplayPassPostProcess which produces an output the same as it's input
  51633. */
  51634. export class DisplayPassPostProcess extends PostProcess {
  51635. /**
  51636. * Creates the DisplayPassPostProcess
  51637. * @param name The name of the effect.
  51638. * @param options The required width/height ratio to downsize to before computing the render pass.
  51639. * @param camera The camera to apply the render pass to.
  51640. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51641. * @param engine The engine which the post process will be applied. (default: current engine)
  51642. * @param reusable If the post process can be reused on the same frame. (default: false)
  51643. */
  51644. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51645. }
  51646. }
  51647. declare module BABYLON {
  51648. /** @hidden */
  51649. export var filterPixelShader: {
  51650. name: string;
  51651. shader: string;
  51652. };
  51653. }
  51654. declare module BABYLON {
  51655. /**
  51656. * Applies a kernel filter to the image
  51657. */
  51658. export class FilterPostProcess extends PostProcess {
  51659. /** The matrix to be applied to the image */
  51660. kernelMatrix: Matrix;
  51661. /**
  51662. *
  51663. * @param name The name of the effect.
  51664. * @param kernelMatrix The matrix to be applied to the image
  51665. * @param options The required width/height ratio to downsize to before computing the render pass.
  51666. * @param camera The camera to apply the render pass to.
  51667. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51668. * @param engine The engine which the post process will be applied. (default: current engine)
  51669. * @param reusable If the post process can be reused on the same frame. (default: false)
  51670. */
  51671. constructor(name: string,
  51672. /** The matrix to be applied to the image */
  51673. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51674. }
  51675. }
  51676. declare module BABYLON {
  51677. /** @hidden */
  51678. export var fxaaPixelShader: {
  51679. name: string;
  51680. shader: string;
  51681. };
  51682. }
  51683. declare module BABYLON {
  51684. /** @hidden */
  51685. export var fxaaVertexShader: {
  51686. name: string;
  51687. shader: string;
  51688. };
  51689. }
  51690. declare module BABYLON {
  51691. /**
  51692. * Fxaa post process
  51693. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  51694. */
  51695. export class FxaaPostProcess extends PostProcess {
  51696. /** @hidden */
  51697. texelWidth: number;
  51698. /** @hidden */
  51699. texelHeight: number;
  51700. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51701. private _getDefines;
  51702. }
  51703. }
  51704. declare module BABYLON {
  51705. /** @hidden */
  51706. export var grainPixelShader: {
  51707. name: string;
  51708. shader: string;
  51709. };
  51710. }
  51711. declare module BABYLON {
  51712. /**
  51713. * The GrainPostProcess adds noise to the image at mid luminance levels
  51714. */
  51715. export class GrainPostProcess extends PostProcess {
  51716. /**
  51717. * The intensity of the grain added (default: 30)
  51718. */
  51719. intensity: number;
  51720. /**
  51721. * If the grain should be randomized on every frame
  51722. */
  51723. animated: boolean;
  51724. /**
  51725. * Creates a new instance of @see GrainPostProcess
  51726. * @param name The name of the effect.
  51727. * @param options The required width/height ratio to downsize to before computing the render pass.
  51728. * @param camera The camera to apply the render pass to.
  51729. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51730. * @param engine The engine which the post process will be applied. (default: current engine)
  51731. * @param reusable If the post process can be reused on the same frame. (default: false)
  51732. * @param textureType Type of textures used when performing the post process. (default: 0)
  51733. * @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)
  51734. */
  51735. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51736. }
  51737. }
  51738. declare module BABYLON {
  51739. /** @hidden */
  51740. export var highlightsPixelShader: {
  51741. name: string;
  51742. shader: string;
  51743. };
  51744. }
  51745. declare module BABYLON {
  51746. /**
  51747. * Extracts highlights from the image
  51748. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  51749. */
  51750. export class HighlightsPostProcess extends PostProcess {
  51751. /**
  51752. * Extracts highlights from the image
  51753. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  51754. * @param name The name of the effect.
  51755. * @param options The required width/height ratio to downsize to before computing the render pass.
  51756. * @param camera The camera to apply the render pass to.
  51757. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51758. * @param engine The engine which the post process will be applied. (default: current engine)
  51759. * @param reusable If the post process can be reused on the same frame. (default: false)
  51760. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  51761. */
  51762. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51763. }
  51764. }
  51765. declare module BABYLON {
  51766. /** @hidden */
  51767. export var mrtFragmentDeclaration: {
  51768. name: string;
  51769. shader: string;
  51770. };
  51771. }
  51772. declare module BABYLON {
  51773. /** @hidden */
  51774. export var geometryPixelShader: {
  51775. name: string;
  51776. shader: string;
  51777. };
  51778. }
  51779. declare module BABYLON {
  51780. /** @hidden */
  51781. export var geometryVertexShader: {
  51782. name: string;
  51783. shader: string;
  51784. };
  51785. }
  51786. declare module BABYLON {
  51787. /**
  51788. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  51789. */
  51790. export class GeometryBufferRenderer {
  51791. /**
  51792. * Constant used to retrieve the position texture index in the G-Buffer textures array
  51793. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  51794. */
  51795. static readonly POSITION_TEXTURE_TYPE: number;
  51796. /**
  51797. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  51798. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  51799. */
  51800. static readonly VELOCITY_TEXTURE_TYPE: number;
  51801. /**
  51802. * Dictionary used to store the previous transformation matrices of each rendered mesh
  51803. * in order to compute objects velocities when enableVelocity is set to "true"
  51804. * @hidden
  51805. */ previousTransformationMatrices: {
  51806. [index: number]: Matrix;
  51807. };
  51808. private _scene;
  51809. private _multiRenderTarget;
  51810. private _ratio;
  51811. private _enablePosition;
  51812. private _enableVelocity;
  51813. private _positionIndex;
  51814. private _velocityIndex;
  51815. protected _effect: Effect;
  51816. protected _cachedDefines: string;
  51817. /**
  51818. * Set the render list (meshes to be rendered) used in the G buffer.
  51819. */
  51820. renderList: Mesh[];
  51821. /**
  51822. * Gets wether or not G buffer are supported by the running hardware.
  51823. * This requires draw buffer supports
  51824. */
  51825. readonly isSupported: boolean;
  51826. /**
  51827. * Returns the index of the given texture type in the G-Buffer textures array
  51828. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  51829. * @returns the index of the given texture type in the G-Buffer textures array
  51830. */
  51831. getTextureIndex(textureType: number): number;
  51832. /**
  51833. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  51834. */
  51835. /**
  51836. * Sets whether or not objects positions are enabled for the G buffer.
  51837. */
  51838. enablePosition: boolean;
  51839. /**
  51840. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  51841. */
  51842. /**
  51843. * Sets wether or not objects velocities are enabled for the G buffer.
  51844. */
  51845. enableVelocity: boolean;
  51846. /**
  51847. * Gets the scene associated with the buffer.
  51848. */
  51849. readonly scene: Scene;
  51850. /**
  51851. * Gets the ratio used by the buffer during its creation.
  51852. * How big is the buffer related to the main canvas.
  51853. */
  51854. readonly ratio: number;
  51855. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  51856. /**
  51857. * Creates a new G Buffer for the scene
  51858. * @param scene The scene the buffer belongs to
  51859. * @param ratio How big is the buffer related to the main canvas.
  51860. */
  51861. constructor(scene: Scene, ratio?: number);
  51862. /**
  51863. * Checks wether everything is ready to render a submesh to the G buffer.
  51864. * @param subMesh the submesh to check readiness for
  51865. * @param useInstances is the mesh drawn using instance or not
  51866. * @returns true if ready otherwise false
  51867. */
  51868. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51869. /**
  51870. * Gets the current underlying G Buffer.
  51871. * @returns the buffer
  51872. */
  51873. getGBuffer(): MultiRenderTarget;
  51874. /**
  51875. * Gets the number of samples used to render the buffer (anti aliasing).
  51876. */
  51877. /**
  51878. * Sets the number of samples used to render the buffer (anti aliasing).
  51879. */
  51880. samples: number;
  51881. /**
  51882. * Disposes the renderer and frees up associated resources.
  51883. */
  51884. dispose(): void;
  51885. protected _createRenderTargets(): void;
  51886. }
  51887. }
  51888. declare module BABYLON {
  51889. interface Scene {
  51890. /** @hidden (Backing field) */ geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51891. /**
  51892. * Gets or Sets the current geometry buffer associated to the scene.
  51893. */
  51894. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51895. /**
  51896. * Enables a GeometryBufferRender and associates it with the scene
  51897. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  51898. * @returns the GeometryBufferRenderer
  51899. */
  51900. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  51901. /**
  51902. * Disables the GeometryBufferRender associated with the scene
  51903. */
  51904. disableGeometryBufferRenderer(): void;
  51905. }
  51906. /**
  51907. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  51908. * in several rendering techniques.
  51909. */
  51910. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  51911. /**
  51912. * The component name helpful to identify the component in the list of scene components.
  51913. */
  51914. readonly name: string;
  51915. /**
  51916. * The scene the component belongs to.
  51917. */
  51918. scene: Scene;
  51919. /**
  51920. * Creates a new instance of the component for the given scene
  51921. * @param scene Defines the scene to register the component in
  51922. */
  51923. constructor(scene: Scene);
  51924. /**
  51925. * Registers the component in a given scene
  51926. */
  51927. register(): void;
  51928. /**
  51929. * Rebuilds the elements related to this component in case of
  51930. * context lost for instance.
  51931. */
  51932. rebuild(): void;
  51933. /**
  51934. * Disposes the component and the associated ressources
  51935. */
  51936. dispose(): void;
  51937. private _gatherRenderTargets;
  51938. }
  51939. }
  51940. declare module BABYLON {
  51941. /** @hidden */
  51942. export var motionBlurPixelShader: {
  51943. name: string;
  51944. shader: string;
  51945. };
  51946. }
  51947. declare module BABYLON {
  51948. /**
  51949. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  51950. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  51951. * As an example, all you have to do is to create the post-process:
  51952. * var mb = new BABYLON.MotionBlurPostProcess(
  51953. * 'mb', // The name of the effect.
  51954. * scene, // The scene containing the objects to blur according to their velocity.
  51955. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  51956. * camera // The camera to apply the render pass to.
  51957. * );
  51958. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  51959. */
  51960. export class MotionBlurPostProcess extends PostProcess {
  51961. /**
  51962. * Defines how much the image is blurred by the movement. Default value is equal to 1
  51963. */
  51964. motionStrength: number;
  51965. /**
  51966. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  51967. */
  51968. /**
  51969. * Sets the number of iterations to be used for motion blur quality
  51970. */
  51971. motionBlurSamples: number;
  51972. private _motionBlurSamples;
  51973. private _geometryBufferRenderer;
  51974. /**
  51975. * Creates a new instance MotionBlurPostProcess
  51976. * @param name The name of the effect.
  51977. * @param scene The scene containing the objects to blur according to their velocity.
  51978. * @param options The required width/height ratio to downsize to before computing the render pass.
  51979. * @param camera The camera to apply the render pass to.
  51980. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51981. * @param engine The engine which the post process will be applied. (default: current engine)
  51982. * @param reusable If the post process can be reused on the same frame. (default: false)
  51983. * @param textureType Type of textures used when performing the post process. (default: 0)
  51984. * @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)
  51985. */
  51986. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51987. /**
  51988. * Disposes the post process.
  51989. * @param camera The camera to dispose the post process on.
  51990. */
  51991. dispose(camera?: Camera): void;
  51992. }
  51993. }
  51994. declare module BABYLON {
  51995. /** @hidden */
  51996. export var refractionPixelShader: {
  51997. name: string;
  51998. shader: string;
  51999. };
  52000. }
  52001. declare module BABYLON {
  52002. /**
  52003. * Post process which applies a refractin texture
  52004. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52005. */
  52006. export class RefractionPostProcess extends PostProcess {
  52007. /** the base color of the refraction (used to taint the rendering) */
  52008. color: Color3;
  52009. /** simulated refraction depth */
  52010. depth: number;
  52011. /** the coefficient of the base color (0 to remove base color tainting) */
  52012. colorLevel: number;
  52013. private _refTexture;
  52014. private _ownRefractionTexture;
  52015. /**
  52016. * Gets or sets the refraction texture
  52017. * Please note that you are responsible for disposing the texture if you set it manually
  52018. */
  52019. refractionTexture: Texture;
  52020. /**
  52021. * Initializes the RefractionPostProcess
  52022. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52023. * @param name The name of the effect.
  52024. * @param refractionTextureUrl Url of the refraction texture to use
  52025. * @param color the base color of the refraction (used to taint the rendering)
  52026. * @param depth simulated refraction depth
  52027. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52028. * @param camera The camera to apply the render pass to.
  52029. * @param options The required width/height ratio to downsize to before computing the render pass.
  52030. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52031. * @param engine The engine which the post process will be applied. (default: current engine)
  52032. * @param reusable If the post process can be reused on the same frame. (default: false)
  52033. */
  52034. constructor(name: string, refractionTextureUrl: string,
  52035. /** the base color of the refraction (used to taint the rendering) */
  52036. color: Color3,
  52037. /** simulated refraction depth */
  52038. depth: number,
  52039. /** the coefficient of the base color (0 to remove base color tainting) */
  52040. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52041. /**
  52042. * Disposes of the post process
  52043. * @param camera Camera to dispose post process on
  52044. */
  52045. dispose(camera: Camera): void;
  52046. }
  52047. }
  52048. declare module BABYLON {
  52049. /** @hidden */
  52050. export var sharpenPixelShader: {
  52051. name: string;
  52052. shader: string;
  52053. };
  52054. }
  52055. declare module BABYLON {
  52056. /**
  52057. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52058. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52059. */
  52060. export class SharpenPostProcess extends PostProcess {
  52061. /**
  52062. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52063. */
  52064. colorAmount: number;
  52065. /**
  52066. * How much sharpness should be applied (default: 0.3)
  52067. */
  52068. edgeAmount: number;
  52069. /**
  52070. * Creates a new instance ConvolutionPostProcess
  52071. * @param name The name of the effect.
  52072. * @param options The required width/height ratio to downsize to before computing the render pass.
  52073. * @param camera The camera to apply the render pass to.
  52074. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52075. * @param engine The engine which the post process will be applied. (default: current engine)
  52076. * @param reusable If the post process can be reused on the same frame. (default: false)
  52077. * @param textureType Type of textures used when performing the post process. (default: 0)
  52078. * @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)
  52079. */
  52080. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52081. }
  52082. }
  52083. declare module BABYLON {
  52084. /**
  52085. * PostProcessRenderPipeline
  52086. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52087. */
  52088. export class PostProcessRenderPipeline {
  52089. private engine;
  52090. private _renderEffects;
  52091. private _renderEffectsForIsolatedPass;
  52092. /**
  52093. * List of inspectable custom properties (used by the Inspector)
  52094. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  52095. */
  52096. inspectableCustomProperties: IInspectable[];
  52097. /**
  52098. * @hidden
  52099. */
  52100. protected _cameras: Camera[];
  52101. /** @hidden */ name: string;
  52102. /**
  52103. * Gets pipeline name
  52104. */
  52105. readonly name: string;
  52106. /**
  52107. * Initializes a PostProcessRenderPipeline
  52108. * @param engine engine to add the pipeline to
  52109. * @param name name of the pipeline
  52110. */
  52111. constructor(engine: Engine, name: string);
  52112. /**
  52113. * Gets the class name
  52114. * @returns "PostProcessRenderPipeline"
  52115. */
  52116. getClassName(): string;
  52117. /**
  52118. * If all the render effects in the pipeline are supported
  52119. */
  52120. readonly isSupported: boolean;
  52121. /**
  52122. * Adds an effect to the pipeline
  52123. * @param renderEffect the effect to add
  52124. */
  52125. addEffect(renderEffect: PostProcessRenderEffect): void;
  52126. /** @hidden */ rebuild(): void;
  52127. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera): void;
  52128. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52129. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52130. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52131. /** @hidden */ attachCameras(cameras: Camera, unique: boolean): void;
  52132. /** @hidden */ attachCameras(cameras: Camera[], unique: boolean): void;
  52133. /** @hidden */ detachCameras(cameras: Camera): void;
  52134. /** @hidden */ detachCameras(cameras: Nullable<Camera[]>): void;
  52135. /** @hidden */ update(): void;
  52136. /** @hidden */ reset(): void;
  52137. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52138. /**
  52139. * Disposes of the pipeline
  52140. */
  52141. dispose(): void;
  52142. }
  52143. }
  52144. declare module BABYLON {
  52145. /**
  52146. * PostProcessRenderPipelineManager class
  52147. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52148. */
  52149. export class PostProcessRenderPipelineManager {
  52150. private _renderPipelines;
  52151. /**
  52152. * Initializes a PostProcessRenderPipelineManager
  52153. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52154. */
  52155. constructor();
  52156. /**
  52157. * Gets the list of supported render pipelines
  52158. */
  52159. readonly supportedPipelines: PostProcessRenderPipeline[];
  52160. /**
  52161. * Adds a pipeline to the manager
  52162. * @param renderPipeline The pipeline to add
  52163. */
  52164. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  52165. /**
  52166. * Attaches a camera to the pipeline
  52167. * @param renderPipelineName The name of the pipeline to attach to
  52168. * @param cameras the camera to attach
  52169. * @param unique if the camera can be attached multiple times to the pipeline
  52170. */
  52171. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  52172. /**
  52173. * Detaches a camera from the pipeline
  52174. * @param renderPipelineName The name of the pipeline to detach from
  52175. * @param cameras the camera to detach
  52176. */
  52177. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  52178. /**
  52179. * Enables an effect by name on a pipeline
  52180. * @param renderPipelineName the name of the pipeline to enable the effect in
  52181. * @param renderEffectName the name of the effect to enable
  52182. * @param cameras the cameras that the effect should be enabled on
  52183. */
  52184. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52185. /**
  52186. * Disables an effect by name on a pipeline
  52187. * @param renderPipelineName the name of the pipeline to disable the effect in
  52188. * @param renderEffectName the name of the effect to disable
  52189. * @param cameras the cameras that the effect should be disabled on
  52190. */
  52191. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52192. /**
  52193. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  52194. */
  52195. update(): void;
  52196. /** @hidden */ rebuild(): void;
  52197. /**
  52198. * Disposes of the manager and pipelines
  52199. */
  52200. dispose(): void;
  52201. }
  52202. }
  52203. declare module BABYLON {
  52204. interface Scene {
  52205. /** @hidden (Backing field) */ postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52206. /**
  52207. * Gets the postprocess render pipeline manager
  52208. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52209. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52210. */
  52211. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52212. }
  52213. /**
  52214. * Defines the Render Pipeline scene component responsible to rendering pipelines
  52215. */
  52216. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  52217. /**
  52218. * The component name helpfull to identify the component in the list of scene components.
  52219. */
  52220. readonly name: string;
  52221. /**
  52222. * The scene the component belongs to.
  52223. */
  52224. scene: Scene;
  52225. /**
  52226. * Creates a new instance of the component for the given scene
  52227. * @param scene Defines the scene to register the component in
  52228. */
  52229. constructor(scene: Scene);
  52230. /**
  52231. * Registers the component in a given scene
  52232. */
  52233. register(): void;
  52234. /**
  52235. * Rebuilds the elements related to this component in case of
  52236. * context lost for instance.
  52237. */
  52238. rebuild(): void;
  52239. /**
  52240. * Disposes the component and the associated ressources
  52241. */
  52242. dispose(): void;
  52243. private _gatherRenderTargets;
  52244. }
  52245. }
  52246. declare module BABYLON {
  52247. /**
  52248. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52249. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52250. */
  52251. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52252. private _scene;
  52253. private _camerasToBeAttached;
  52254. /**
  52255. * ID of the sharpen post process,
  52256. */
  52257. private readonly SharpenPostProcessId;
  52258. /**
  52259. * @ignore
  52260. * ID of the image processing post process;
  52261. */
  52262. readonly ImageProcessingPostProcessId: string;
  52263. /**
  52264. * @ignore
  52265. * ID of the Fast Approximate Anti-Aliasing post process;
  52266. */
  52267. readonly FxaaPostProcessId: string;
  52268. /**
  52269. * ID of the chromatic aberration post process,
  52270. */
  52271. private readonly ChromaticAberrationPostProcessId;
  52272. /**
  52273. * ID of the grain post process
  52274. */
  52275. private readonly GrainPostProcessId;
  52276. /**
  52277. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52278. */
  52279. sharpen: SharpenPostProcess;
  52280. private _sharpenEffect;
  52281. private bloom;
  52282. /**
  52283. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52284. */
  52285. depthOfField: DepthOfFieldEffect;
  52286. /**
  52287. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52288. */
  52289. fxaa: FxaaPostProcess;
  52290. /**
  52291. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52292. */
  52293. imageProcessing: ImageProcessingPostProcess;
  52294. /**
  52295. * Chromatic aberration post process which will shift rgb colors in the image
  52296. */
  52297. chromaticAberration: ChromaticAberrationPostProcess;
  52298. private _chromaticAberrationEffect;
  52299. /**
  52300. * Grain post process which add noise to the image
  52301. */
  52302. grain: GrainPostProcess;
  52303. private _grainEffect;
  52304. /**
  52305. * Glow post process which adds a glow to emissive areas of the image
  52306. */
  52307. private _glowLayer;
  52308. /**
  52309. * Animations which can be used to tweak settings over a period of time
  52310. */
  52311. animations: Animation[];
  52312. private _imageProcessingConfigurationObserver;
  52313. private _sharpenEnabled;
  52314. private _bloomEnabled;
  52315. private _depthOfFieldEnabled;
  52316. private _depthOfFieldBlurLevel;
  52317. private _fxaaEnabled;
  52318. private _imageProcessingEnabled;
  52319. private _defaultPipelineTextureType;
  52320. private _bloomScale;
  52321. private _chromaticAberrationEnabled;
  52322. private _grainEnabled;
  52323. private _buildAllowed;
  52324. /**
  52325. * Gets active scene
  52326. */
  52327. readonly scene: Scene;
  52328. /**
  52329. * Enable or disable the sharpen process from the pipeline
  52330. */
  52331. sharpenEnabled: boolean;
  52332. private _resizeObserver;
  52333. private _hardwareScaleLevel;
  52334. private _bloomKernel;
  52335. /**
  52336. * Specifies the size of the bloom blur kernel, relative to the final output size
  52337. */
  52338. bloomKernel: number;
  52339. /**
  52340. * Specifies the weight of the bloom in the final rendering
  52341. */
  52342. private _bloomWeight;
  52343. /**
  52344. * Specifies the luma threshold for the area that will be blurred by the bloom
  52345. */
  52346. private _bloomThreshold;
  52347. private _hdr;
  52348. /**
  52349. * The strength of the bloom.
  52350. */
  52351. bloomWeight: number;
  52352. /**
  52353. * The strength of the bloom.
  52354. */
  52355. bloomThreshold: number;
  52356. /**
  52357. * The scale of the bloom, lower value will provide better performance.
  52358. */
  52359. bloomScale: number;
  52360. /**
  52361. * Enable or disable the bloom from the pipeline
  52362. */
  52363. bloomEnabled: boolean;
  52364. private _rebuildBloom;
  52365. /**
  52366. * If the depth of field is enabled.
  52367. */
  52368. depthOfFieldEnabled: boolean;
  52369. /**
  52370. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52371. */
  52372. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52373. /**
  52374. * If the anti aliasing is enabled.
  52375. */
  52376. fxaaEnabled: boolean;
  52377. private _samples;
  52378. /**
  52379. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52380. */
  52381. samples: number;
  52382. /**
  52383. * If image processing is enabled.
  52384. */
  52385. imageProcessingEnabled: boolean;
  52386. /**
  52387. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52388. */
  52389. glowLayerEnabled: boolean;
  52390. /**
  52391. * Enable or disable the chromaticAberration process from the pipeline
  52392. */
  52393. chromaticAberrationEnabled: boolean;
  52394. /**
  52395. * Enable or disable the grain process from the pipeline
  52396. */
  52397. grainEnabled: boolean;
  52398. /**
  52399. * @constructor
  52400. * @param name - The rendering pipeline name (default: "")
  52401. * @param hdr - If high dynamic range textures should be used (default: true)
  52402. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52403. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52404. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52405. */
  52406. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52407. /**
  52408. * Get the class name
  52409. * @returns "DefaultRenderingPipeline"
  52410. */
  52411. getClassName(): string;
  52412. /**
  52413. * Force the compilation of the entire pipeline.
  52414. */
  52415. prepare(): void;
  52416. private _hasCleared;
  52417. private _prevPostProcess;
  52418. private _prevPrevPostProcess;
  52419. private _setAutoClearAndTextureSharing;
  52420. private _depthOfFieldSceneObserver;
  52421. private _buildPipeline;
  52422. private _disposePostProcesses;
  52423. /**
  52424. * Adds a camera to the pipeline
  52425. * @param camera the camera to be added
  52426. */
  52427. addCamera(camera: Camera): void;
  52428. /**
  52429. * Removes a camera from the pipeline
  52430. * @param camera the camera to remove
  52431. */
  52432. removeCamera(camera: Camera): void;
  52433. /**
  52434. * Dispose of the pipeline and stop all post processes
  52435. */
  52436. dispose(): void;
  52437. /**
  52438. * Serialize the rendering pipeline (Used when exporting)
  52439. * @returns the serialized object
  52440. */
  52441. serialize(): any;
  52442. /**
  52443. * Parse the serialized pipeline
  52444. * @param source Source pipeline.
  52445. * @param scene The scene to load the pipeline to.
  52446. * @param rootUrl The URL of the serialized pipeline.
  52447. * @returns An instantiated pipeline from the serialized object.
  52448. */
  52449. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52450. }
  52451. }
  52452. declare module BABYLON {
  52453. /** @hidden */
  52454. export var lensHighlightsPixelShader: {
  52455. name: string;
  52456. shader: string;
  52457. };
  52458. }
  52459. declare module BABYLON {
  52460. /** @hidden */
  52461. export var depthOfFieldPixelShader: {
  52462. name: string;
  52463. shader: string;
  52464. };
  52465. }
  52466. declare module BABYLON {
  52467. /**
  52468. * BABYLON.JS Chromatic Aberration GLSL Shader
  52469. * Author: Olivier Guyot
  52470. * Separates very slightly R, G and B colors on the edges of the screen
  52471. * Inspired by Francois Tarlier & Martins Upitis
  52472. */
  52473. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52474. /**
  52475. * @ignore
  52476. * The chromatic aberration PostProcess id in the pipeline
  52477. */
  52478. LensChromaticAberrationEffect: string;
  52479. /**
  52480. * @ignore
  52481. * The highlights enhancing PostProcess id in the pipeline
  52482. */
  52483. HighlightsEnhancingEffect: string;
  52484. /**
  52485. * @ignore
  52486. * The depth-of-field PostProcess id in the pipeline
  52487. */
  52488. LensDepthOfFieldEffect: string;
  52489. private _scene;
  52490. private _depthTexture;
  52491. private _grainTexture;
  52492. private _chromaticAberrationPostProcess;
  52493. private _highlightsPostProcess;
  52494. private _depthOfFieldPostProcess;
  52495. private _edgeBlur;
  52496. private _grainAmount;
  52497. private _chromaticAberration;
  52498. private _distortion;
  52499. private _highlightsGain;
  52500. private _highlightsThreshold;
  52501. private _dofDistance;
  52502. private _dofAperture;
  52503. private _dofDarken;
  52504. private _dofPentagon;
  52505. private _blurNoise;
  52506. /**
  52507. * @constructor
  52508. *
  52509. * Effect parameters are as follow:
  52510. * {
  52511. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52512. * edge_blur: number; // from 0 to x (1 for realism)
  52513. * distortion: number; // from 0 to x (1 for realism)
  52514. * grain_amount: number; // from 0 to 1
  52515. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52516. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52517. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52518. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52519. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52520. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52521. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52522. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52523. * }
  52524. * Note: if an effect parameter is unset, effect is disabled
  52525. *
  52526. * @param name The rendering pipeline name
  52527. * @param parameters - An object containing all parameters (see above)
  52528. * @param scene The scene linked to this pipeline
  52529. * @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)
  52530. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52531. */
  52532. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52533. /**
  52534. * Get the class name
  52535. * @returns "LensRenderingPipeline"
  52536. */
  52537. getClassName(): string;
  52538. /**
  52539. * Gets associated scene
  52540. */
  52541. readonly scene: Scene;
  52542. /**
  52543. * Gets or sets the edge blur
  52544. */
  52545. edgeBlur: number;
  52546. /**
  52547. * Gets or sets the grain amount
  52548. */
  52549. grainAmount: number;
  52550. /**
  52551. * Gets or sets the chromatic aberration amount
  52552. */
  52553. chromaticAberration: number;
  52554. /**
  52555. * Gets or sets the depth of field aperture
  52556. */
  52557. dofAperture: number;
  52558. /**
  52559. * Gets or sets the edge distortion
  52560. */
  52561. edgeDistortion: number;
  52562. /**
  52563. * Gets or sets the depth of field distortion
  52564. */
  52565. dofDistortion: number;
  52566. /**
  52567. * Gets or sets the darken out of focus amount
  52568. */
  52569. darkenOutOfFocus: number;
  52570. /**
  52571. * Gets or sets a boolean indicating if blur noise is enabled
  52572. */
  52573. blurNoise: boolean;
  52574. /**
  52575. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  52576. */
  52577. pentagonBokeh: boolean;
  52578. /**
  52579. * Gets or sets the highlight grain amount
  52580. */
  52581. highlightsGain: number;
  52582. /**
  52583. * Gets or sets the highlight threshold
  52584. */
  52585. highlightsThreshold: number;
  52586. /**
  52587. * Sets the amount of blur at the edges
  52588. * @param amount blur amount
  52589. */
  52590. setEdgeBlur(amount: number): void;
  52591. /**
  52592. * Sets edge blur to 0
  52593. */
  52594. disableEdgeBlur(): void;
  52595. /**
  52596. * Sets the amout of grain
  52597. * @param amount Amount of grain
  52598. */
  52599. setGrainAmount(amount: number): void;
  52600. /**
  52601. * Set grain amount to 0
  52602. */
  52603. disableGrain(): void;
  52604. /**
  52605. * Sets the chromatic aberration amount
  52606. * @param amount amount of chromatic aberration
  52607. */
  52608. setChromaticAberration(amount: number): void;
  52609. /**
  52610. * Sets chromatic aberration amount to 0
  52611. */
  52612. disableChromaticAberration(): void;
  52613. /**
  52614. * Sets the EdgeDistortion amount
  52615. * @param amount amount of EdgeDistortion
  52616. */
  52617. setEdgeDistortion(amount: number): void;
  52618. /**
  52619. * Sets edge distortion to 0
  52620. */
  52621. disableEdgeDistortion(): void;
  52622. /**
  52623. * Sets the FocusDistance amount
  52624. * @param amount amount of FocusDistance
  52625. */
  52626. setFocusDistance(amount: number): void;
  52627. /**
  52628. * Disables depth of field
  52629. */
  52630. disableDepthOfField(): void;
  52631. /**
  52632. * Sets the Aperture amount
  52633. * @param amount amount of Aperture
  52634. */
  52635. setAperture(amount: number): void;
  52636. /**
  52637. * Sets the DarkenOutOfFocus amount
  52638. * @param amount amount of DarkenOutOfFocus
  52639. */
  52640. setDarkenOutOfFocus(amount: number): void;
  52641. private _pentagonBokehIsEnabled;
  52642. /**
  52643. * Creates a pentagon bokeh effect
  52644. */
  52645. enablePentagonBokeh(): void;
  52646. /**
  52647. * Disables the pentagon bokeh effect
  52648. */
  52649. disablePentagonBokeh(): void;
  52650. /**
  52651. * Enables noise blur
  52652. */
  52653. enableNoiseBlur(): void;
  52654. /**
  52655. * Disables noise blur
  52656. */
  52657. disableNoiseBlur(): void;
  52658. /**
  52659. * Sets the HighlightsGain amount
  52660. * @param amount amount of HighlightsGain
  52661. */
  52662. setHighlightsGain(amount: number): void;
  52663. /**
  52664. * Sets the HighlightsThreshold amount
  52665. * @param amount amount of HighlightsThreshold
  52666. */
  52667. setHighlightsThreshold(amount: number): void;
  52668. /**
  52669. * Disables highlights
  52670. */
  52671. disableHighlights(): void;
  52672. /**
  52673. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  52674. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  52675. */
  52676. dispose(disableDepthRender?: boolean): void;
  52677. private _createChromaticAberrationPostProcess;
  52678. private _createHighlightsPostProcess;
  52679. private _createDepthOfFieldPostProcess;
  52680. private _createGrainTexture;
  52681. }
  52682. }
  52683. declare module BABYLON {
  52684. /** @hidden */
  52685. export var ssao2PixelShader: {
  52686. name: string;
  52687. shader: string;
  52688. };
  52689. }
  52690. declare module BABYLON {
  52691. /** @hidden */
  52692. export var ssaoCombinePixelShader: {
  52693. name: string;
  52694. shader: string;
  52695. };
  52696. }
  52697. declare module BABYLON {
  52698. /**
  52699. * Render pipeline to produce ssao effect
  52700. */
  52701. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  52702. /**
  52703. * @ignore
  52704. * The PassPostProcess id in the pipeline that contains the original scene color
  52705. */
  52706. SSAOOriginalSceneColorEffect: string;
  52707. /**
  52708. * @ignore
  52709. * The SSAO PostProcess id in the pipeline
  52710. */
  52711. SSAORenderEffect: string;
  52712. /**
  52713. * @ignore
  52714. * The horizontal blur PostProcess id in the pipeline
  52715. */
  52716. SSAOBlurHRenderEffect: string;
  52717. /**
  52718. * @ignore
  52719. * The vertical blur PostProcess id in the pipeline
  52720. */
  52721. SSAOBlurVRenderEffect: string;
  52722. /**
  52723. * @ignore
  52724. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  52725. */
  52726. SSAOCombineRenderEffect: string;
  52727. /**
  52728. * The output strength of the SSAO post-process. Default value is 1.0.
  52729. */
  52730. totalStrength: number;
  52731. /**
  52732. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  52733. */
  52734. maxZ: number;
  52735. /**
  52736. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  52737. */
  52738. minZAspect: number;
  52739. private _samples;
  52740. /**
  52741. * Number of samples used for the SSAO calculations. Default value is 8
  52742. */
  52743. samples: number;
  52744. private _textureSamples;
  52745. /**
  52746. * Number of samples to use for antialiasing
  52747. */
  52748. textureSamples: number;
  52749. /**
  52750. * Ratio object used for SSAO ratio and blur ratio
  52751. */
  52752. private _ratio;
  52753. /**
  52754. * Dynamically generated sphere sampler.
  52755. */
  52756. private _sampleSphere;
  52757. /**
  52758. * Blur filter offsets
  52759. */
  52760. private _samplerOffsets;
  52761. private _expensiveBlur;
  52762. /**
  52763. * If bilateral blur should be used
  52764. */
  52765. expensiveBlur: boolean;
  52766. /**
  52767. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  52768. */
  52769. radius: number;
  52770. /**
  52771. * The base color of the SSAO post-process
  52772. * The final result is "base + ssao" between [0, 1]
  52773. */
  52774. base: number;
  52775. /**
  52776. * Support test.
  52777. */
  52778. static readonly IsSupported: boolean;
  52779. private _scene;
  52780. private _depthTexture;
  52781. private _normalTexture;
  52782. private _randomTexture;
  52783. private _originalColorPostProcess;
  52784. private _ssaoPostProcess;
  52785. private _blurHPostProcess;
  52786. private _blurVPostProcess;
  52787. private _ssaoCombinePostProcess;
  52788. private _firstUpdate;
  52789. /**
  52790. * Gets active scene
  52791. */
  52792. readonly scene: Scene;
  52793. /**
  52794. * @constructor
  52795. * @param name The rendering pipeline name
  52796. * @param scene The scene linked to this pipeline
  52797. * @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 }
  52798. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52799. */
  52800. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  52801. /**
  52802. * Get the class name
  52803. * @returns "SSAO2RenderingPipeline"
  52804. */
  52805. getClassName(): string;
  52806. /**
  52807. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  52808. */
  52809. dispose(disableGeometryBufferRenderer?: boolean): void;
  52810. private _createBlurPostProcess;
  52811. /** @hidden */ rebuild(): void;
  52812. private _bits;
  52813. private _radicalInverse_VdC;
  52814. private _hammersley;
  52815. private _hemisphereSample_uniform;
  52816. private _generateHemisphere;
  52817. private _createSSAOPostProcess;
  52818. private _createSSAOCombinePostProcess;
  52819. private _createRandomTexture;
  52820. /**
  52821. * Serialize the rendering pipeline (Used when exporting)
  52822. * @returns the serialized object
  52823. */
  52824. serialize(): any;
  52825. /**
  52826. * Parse the serialized pipeline
  52827. * @param source Source pipeline.
  52828. * @param scene The scene to load the pipeline to.
  52829. * @param rootUrl The URL of the serialized pipeline.
  52830. * @returns An instantiated pipeline from the serialized object.
  52831. */
  52832. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  52833. }
  52834. }
  52835. declare module BABYLON {
  52836. /** @hidden */
  52837. export var ssaoPixelShader: {
  52838. name: string;
  52839. shader: string;
  52840. };
  52841. }
  52842. declare module BABYLON {
  52843. /**
  52844. * Render pipeline to produce ssao effect
  52845. */
  52846. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  52847. /**
  52848. * @ignore
  52849. * The PassPostProcess id in the pipeline that contains the original scene color
  52850. */
  52851. SSAOOriginalSceneColorEffect: string;
  52852. /**
  52853. * @ignore
  52854. * The SSAO PostProcess id in the pipeline
  52855. */
  52856. SSAORenderEffect: string;
  52857. /**
  52858. * @ignore
  52859. * The horizontal blur PostProcess id in the pipeline
  52860. */
  52861. SSAOBlurHRenderEffect: string;
  52862. /**
  52863. * @ignore
  52864. * The vertical blur PostProcess id in the pipeline
  52865. */
  52866. SSAOBlurVRenderEffect: string;
  52867. /**
  52868. * @ignore
  52869. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  52870. */
  52871. SSAOCombineRenderEffect: string;
  52872. /**
  52873. * The output strength of the SSAO post-process. Default value is 1.0.
  52874. */
  52875. totalStrength: number;
  52876. /**
  52877. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  52878. */
  52879. radius: number;
  52880. /**
  52881. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  52882. * Must not be equal to fallOff and superior to fallOff.
  52883. * Default value is 0.0075
  52884. */
  52885. area: number;
  52886. /**
  52887. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  52888. * Must not be equal to area and inferior to area.
  52889. * Default value is 0.000001
  52890. */
  52891. fallOff: number;
  52892. /**
  52893. * The base color of the SSAO post-process
  52894. * The final result is "base + ssao" between [0, 1]
  52895. */
  52896. base: number;
  52897. private _scene;
  52898. private _depthTexture;
  52899. private _randomTexture;
  52900. private _originalColorPostProcess;
  52901. private _ssaoPostProcess;
  52902. private _blurHPostProcess;
  52903. private _blurVPostProcess;
  52904. private _ssaoCombinePostProcess;
  52905. private _firstUpdate;
  52906. /**
  52907. * Gets active scene
  52908. */
  52909. readonly scene: Scene;
  52910. /**
  52911. * @constructor
  52912. * @param name - The rendering pipeline name
  52913. * @param scene - The scene linked to this pipeline
  52914. * @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 }
  52915. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  52916. */
  52917. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  52918. /**
  52919. * Get the class name
  52920. * @returns "SSAORenderingPipeline"
  52921. */
  52922. getClassName(): string;
  52923. /**
  52924. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  52925. */
  52926. dispose(disableDepthRender?: boolean): void;
  52927. private _createBlurPostProcess;
  52928. /** @hidden */ rebuild(): void;
  52929. private _createSSAOPostProcess;
  52930. private _createSSAOCombinePostProcess;
  52931. private _createRandomTexture;
  52932. }
  52933. }
  52934. declare module BABYLON {
  52935. /** @hidden */
  52936. export var standardPixelShader: {
  52937. name: string;
  52938. shader: string;
  52939. };
  52940. }
  52941. declare module BABYLON {
  52942. /**
  52943. * Standard rendering pipeline
  52944. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  52945. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  52946. */
  52947. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52948. /**
  52949. * Public members
  52950. */
  52951. /**
  52952. * Post-process which contains the original scene color before the pipeline applies all the effects
  52953. */
  52954. originalPostProcess: Nullable<PostProcess>;
  52955. /**
  52956. * Post-process used to down scale an image x4
  52957. */
  52958. downSampleX4PostProcess: Nullable<PostProcess>;
  52959. /**
  52960. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  52961. */
  52962. brightPassPostProcess: Nullable<PostProcess>;
  52963. /**
  52964. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  52965. */
  52966. blurHPostProcesses: PostProcess[];
  52967. /**
  52968. * Post-process array storing all the vertical blur post-processes used by the pipeline
  52969. */
  52970. blurVPostProcesses: PostProcess[];
  52971. /**
  52972. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  52973. */
  52974. textureAdderPostProcess: Nullable<PostProcess>;
  52975. /**
  52976. * Post-process used to create volumetric lighting effect
  52977. */
  52978. volumetricLightPostProcess: Nullable<PostProcess>;
  52979. /**
  52980. * Post-process used to smooth the previous volumetric light post-process on the X axis
  52981. */
  52982. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  52983. /**
  52984. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  52985. */
  52986. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  52987. /**
  52988. * Post-process used to merge the volumetric light effect and the real scene color
  52989. */
  52990. volumetricLightMergePostProces: Nullable<PostProcess>;
  52991. /**
  52992. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  52993. */
  52994. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  52995. /**
  52996. * Base post-process used to calculate the average luminance of the final image for HDR
  52997. */
  52998. luminancePostProcess: Nullable<PostProcess>;
  52999. /**
  53000. * Post-processes used to create down sample post-processes in order to get
  53001. * the average luminance of the final image for HDR
  53002. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53003. */
  53004. luminanceDownSamplePostProcesses: PostProcess[];
  53005. /**
  53006. * Post-process used to create a HDR effect (light adaptation)
  53007. */
  53008. hdrPostProcess: Nullable<PostProcess>;
  53009. /**
  53010. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53011. */
  53012. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53013. /**
  53014. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53015. */
  53016. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53017. /**
  53018. * Post-process used to merge the final HDR post-process and the real scene color
  53019. */
  53020. hdrFinalPostProcess: Nullable<PostProcess>;
  53021. /**
  53022. * Post-process used to create a lens flare effect
  53023. */
  53024. lensFlarePostProcess: Nullable<PostProcess>;
  53025. /**
  53026. * Post-process that merges the result of the lens flare post-process and the real scene color
  53027. */
  53028. lensFlareComposePostProcess: Nullable<PostProcess>;
  53029. /**
  53030. * Post-process used to create a motion blur effect
  53031. */
  53032. motionBlurPostProcess: Nullable<PostProcess>;
  53033. /**
  53034. * Post-process used to create a depth of field effect
  53035. */
  53036. depthOfFieldPostProcess: Nullable<PostProcess>;
  53037. /**
  53038. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53039. */
  53040. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53041. /**
  53042. * Represents the brightness threshold in order to configure the illuminated surfaces
  53043. */
  53044. brightThreshold: number;
  53045. /**
  53046. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53047. */
  53048. blurWidth: number;
  53049. /**
  53050. * Sets if the blur for highlighted surfaces must be only horizontal
  53051. */
  53052. horizontalBlur: boolean;
  53053. /**
  53054. * Gets the overall exposure used by the pipeline
  53055. */
  53056. /**
  53057. * Sets the overall exposure used by the pipeline
  53058. */
  53059. exposure: number;
  53060. /**
  53061. * Texture used typically to simulate "dirty" on camera lens
  53062. */
  53063. lensTexture: Nullable<Texture>;
  53064. /**
  53065. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53066. */
  53067. volumetricLightCoefficient: number;
  53068. /**
  53069. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53070. */
  53071. volumetricLightPower: number;
  53072. /**
  53073. * Used the set the blur intensity to smooth the volumetric lights
  53074. */
  53075. volumetricLightBlurScale: number;
  53076. /**
  53077. * Light (spot or directional) used to generate the volumetric lights rays
  53078. * The source light must have a shadow generate so the pipeline can get its
  53079. * depth map
  53080. */
  53081. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53082. /**
  53083. * For eye adaptation, represents the minimum luminance the eye can see
  53084. */
  53085. hdrMinimumLuminance: number;
  53086. /**
  53087. * For eye adaptation, represents the decrease luminance speed
  53088. */
  53089. hdrDecreaseRate: number;
  53090. /**
  53091. * For eye adaptation, represents the increase luminance speed
  53092. */
  53093. hdrIncreaseRate: number;
  53094. /**
  53095. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53096. */
  53097. /**
  53098. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53099. */
  53100. hdrAutoExposure: boolean;
  53101. /**
  53102. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53103. */
  53104. lensColorTexture: Nullable<Texture>;
  53105. /**
  53106. * The overall strengh for the lens flare effect
  53107. */
  53108. lensFlareStrength: number;
  53109. /**
  53110. * Dispersion coefficient for lens flare ghosts
  53111. */
  53112. lensFlareGhostDispersal: number;
  53113. /**
  53114. * Main lens flare halo width
  53115. */
  53116. lensFlareHaloWidth: number;
  53117. /**
  53118. * Based on the lens distortion effect, defines how much the lens flare result
  53119. * is distorted
  53120. */
  53121. lensFlareDistortionStrength: number;
  53122. /**
  53123. * Lens star texture must be used to simulate rays on the flares and is available
  53124. * in the documentation
  53125. */
  53126. lensStarTexture: Nullable<Texture>;
  53127. /**
  53128. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53129. * flare effect by taking account of the dirt texture
  53130. */
  53131. lensFlareDirtTexture: Nullable<Texture>;
  53132. /**
  53133. * Represents the focal length for the depth of field effect
  53134. */
  53135. depthOfFieldDistance: number;
  53136. /**
  53137. * Represents the blur intensity for the blurred part of the depth of field effect
  53138. */
  53139. depthOfFieldBlurWidth: number;
  53140. /**
  53141. * For motion blur, defines how much the image is blurred by the movement
  53142. */
  53143. motionStrength: number;
  53144. /**
  53145. * List of animations for the pipeline (IAnimatable implementation)
  53146. */
  53147. animations: Animation[];
  53148. /**
  53149. * Private members
  53150. */
  53151. private _scene;
  53152. private _currentDepthOfFieldSource;
  53153. private _basePostProcess;
  53154. private _fixedExposure;
  53155. private _currentExposure;
  53156. private _hdrAutoExposure;
  53157. private _hdrCurrentLuminance;
  53158. private _floatTextureType;
  53159. private _ratio;
  53160. private _bloomEnabled;
  53161. private _depthOfFieldEnabled;
  53162. private _vlsEnabled;
  53163. private _lensFlareEnabled;
  53164. private _hdrEnabled;
  53165. private _motionBlurEnabled;
  53166. private _fxaaEnabled;
  53167. private _motionBlurSamples;
  53168. private _volumetricLightStepsCount;
  53169. private _samples;
  53170. /**
  53171. * @ignore
  53172. * Specifies if the bloom pipeline is enabled
  53173. */
  53174. BloomEnabled: boolean;
  53175. /**
  53176. * @ignore
  53177. * Specifies if the depth of field pipeline is enabed
  53178. */
  53179. DepthOfFieldEnabled: boolean;
  53180. /**
  53181. * @ignore
  53182. * Specifies if the lens flare pipeline is enabed
  53183. */
  53184. LensFlareEnabled: boolean;
  53185. /**
  53186. * @ignore
  53187. * Specifies if the HDR pipeline is enabled
  53188. */
  53189. HDREnabled: boolean;
  53190. /**
  53191. * @ignore
  53192. * Specifies if the volumetric lights scattering effect is enabled
  53193. */
  53194. VLSEnabled: boolean;
  53195. /**
  53196. * @ignore
  53197. * Specifies if the motion blur effect is enabled
  53198. */
  53199. MotionBlurEnabled: boolean;
  53200. /**
  53201. * Specifies if anti-aliasing is enabled
  53202. */
  53203. fxaaEnabled: boolean;
  53204. /**
  53205. * Specifies the number of steps used to calculate the volumetric lights
  53206. * Typically in interval [50, 200]
  53207. */
  53208. volumetricLightStepsCount: number;
  53209. /**
  53210. * Specifies the number of samples used for the motion blur effect
  53211. * Typically in interval [16, 64]
  53212. */
  53213. motionBlurSamples: number;
  53214. /**
  53215. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53216. */
  53217. samples: number;
  53218. /**
  53219. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53220. * @constructor
  53221. * @param name The rendering pipeline name
  53222. * @param scene The scene linked to this pipeline
  53223. * @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)
  53224. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53225. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53226. */
  53227. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53228. private _buildPipeline;
  53229. private _createDownSampleX4PostProcess;
  53230. private _createBrightPassPostProcess;
  53231. private _createBlurPostProcesses;
  53232. private _createTextureAdderPostProcess;
  53233. private _createVolumetricLightPostProcess;
  53234. private _createLuminancePostProcesses;
  53235. private _createHdrPostProcess;
  53236. private _createLensFlarePostProcess;
  53237. private _createDepthOfFieldPostProcess;
  53238. private _createMotionBlurPostProcess;
  53239. private _getDepthTexture;
  53240. private _disposePostProcesses;
  53241. /**
  53242. * Dispose of the pipeline and stop all post processes
  53243. */
  53244. dispose(): void;
  53245. /**
  53246. * Serialize the rendering pipeline (Used when exporting)
  53247. * @returns the serialized object
  53248. */
  53249. serialize(): any;
  53250. /**
  53251. * Parse the serialized pipeline
  53252. * @param source Source pipeline.
  53253. * @param scene The scene to load the pipeline to.
  53254. * @param rootUrl The URL of the serialized pipeline.
  53255. * @returns An instantiated pipeline from the serialized object.
  53256. */
  53257. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53258. /**
  53259. * Luminance steps
  53260. */
  53261. static LuminanceSteps: number;
  53262. }
  53263. }
  53264. declare module BABYLON {
  53265. /** @hidden */
  53266. export var tonemapPixelShader: {
  53267. name: string;
  53268. shader: string;
  53269. };
  53270. }
  53271. declare module BABYLON {
  53272. /** Defines operator used for tonemapping */
  53273. export enum TonemappingOperator {
  53274. /** Hable */
  53275. Hable = 0,
  53276. /** Reinhard */
  53277. Reinhard = 1,
  53278. /** HejiDawson */
  53279. HejiDawson = 2,
  53280. /** Photographic */
  53281. Photographic = 3
  53282. }
  53283. /**
  53284. * Defines a post process to apply tone mapping
  53285. */
  53286. export class TonemapPostProcess extends PostProcess {
  53287. private _operator;
  53288. /** Defines the required exposure adjustement */
  53289. exposureAdjustment: number;
  53290. /**
  53291. * Creates a new TonemapPostProcess
  53292. * @param name defines the name of the postprocess
  53293. * @param _operator defines the operator to use
  53294. * @param exposureAdjustment defines the required exposure adjustement
  53295. * @param camera defines the camera to use (can be null)
  53296. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53297. * @param engine defines the hosting engine (can be ignore if camera is set)
  53298. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53299. */
  53300. constructor(name: string, _operator: TonemappingOperator,
  53301. /** Defines the required exposure adjustement */
  53302. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53303. }
  53304. }
  53305. declare module BABYLON {
  53306. /** @hidden */
  53307. export var depthVertexShader: {
  53308. name: string;
  53309. shader: string;
  53310. };
  53311. }
  53312. declare module BABYLON {
  53313. /** @hidden */
  53314. export var volumetricLightScatteringPixelShader: {
  53315. name: string;
  53316. shader: string;
  53317. };
  53318. }
  53319. declare module BABYLON {
  53320. /** @hidden */
  53321. export var volumetricLightScatteringPassPixelShader: {
  53322. name: string;
  53323. shader: string;
  53324. };
  53325. }
  53326. declare module BABYLON {
  53327. /**
  53328. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53329. */
  53330. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53331. private _volumetricLightScatteringPass;
  53332. private _volumetricLightScatteringRTT;
  53333. private _viewPort;
  53334. private _screenCoordinates;
  53335. private _cachedDefines;
  53336. /**
  53337. * If not undefined, the mesh position is computed from the attached node position
  53338. */
  53339. attachedNode: {
  53340. position: Vector3;
  53341. };
  53342. /**
  53343. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53344. */
  53345. customMeshPosition: Vector3;
  53346. /**
  53347. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53348. */
  53349. useCustomMeshPosition: boolean;
  53350. /**
  53351. * If the post-process should inverse the light scattering direction
  53352. */
  53353. invert: boolean;
  53354. /**
  53355. * The internal mesh used by the post-process
  53356. */
  53357. mesh: Mesh;
  53358. /**
  53359. * @hidden
  53360. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53361. */
  53362. useDiffuseColor: boolean;
  53363. /**
  53364. * Array containing the excluded meshes not rendered in the internal pass
  53365. */
  53366. excludedMeshes: AbstractMesh[];
  53367. /**
  53368. * Controls the overall intensity of the post-process
  53369. */
  53370. exposure: number;
  53371. /**
  53372. * Dissipates each sample's contribution in range [0, 1]
  53373. */
  53374. decay: number;
  53375. /**
  53376. * Controls the overall intensity of each sample
  53377. */
  53378. weight: number;
  53379. /**
  53380. * Controls the density of each sample
  53381. */
  53382. density: number;
  53383. /**
  53384. * @constructor
  53385. * @param name The post-process name
  53386. * @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)
  53387. * @param camera The camera that the post-process will be attached to
  53388. * @param mesh The mesh used to create the light scattering
  53389. * @param samples The post-process quality, default 100
  53390. * @param samplingModeThe post-process filtering mode
  53391. * @param engine The babylon engine
  53392. * @param reusable If the post-process is reusable
  53393. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53394. */
  53395. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53396. /**
  53397. * Returns the string "VolumetricLightScatteringPostProcess"
  53398. * @returns "VolumetricLightScatteringPostProcess"
  53399. */
  53400. getClassName(): string;
  53401. private _isReady;
  53402. /**
  53403. * Sets the new light position for light scattering effect
  53404. * @param position The new custom light position
  53405. */
  53406. setCustomMeshPosition(position: Vector3): void;
  53407. /**
  53408. * Returns the light position for light scattering effect
  53409. * @return Vector3 The custom light position
  53410. */
  53411. getCustomMeshPosition(): Vector3;
  53412. /**
  53413. * Disposes the internal assets and detaches the post-process from the camera
  53414. */
  53415. dispose(camera: Camera): void;
  53416. /**
  53417. * Returns the render target texture used by the post-process
  53418. * @return the render target texture used by the post-process
  53419. */
  53420. getPass(): RenderTargetTexture;
  53421. private _meshExcluded;
  53422. private _createPass;
  53423. private _updateMeshScreenCoordinates;
  53424. /**
  53425. * Creates a default mesh for the Volumeric Light Scattering post-process
  53426. * @param name The mesh name
  53427. * @param scene The scene where to create the mesh
  53428. * @return the default mesh
  53429. */
  53430. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53431. }
  53432. }
  53433. declare module BABYLON {
  53434. interface Scene {
  53435. /** @hidden (Backing field) */ boundingBoxRenderer: BoundingBoxRenderer;
  53436. /** @hidden (Backing field) */ forceShowBoundingBoxes: boolean;
  53437. /**
  53438. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53439. */
  53440. forceShowBoundingBoxes: boolean;
  53441. /**
  53442. * Gets the bounding box renderer associated with the scene
  53443. * @returns a BoundingBoxRenderer
  53444. */
  53445. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53446. }
  53447. interface AbstractMesh {
  53448. /** @hidden (Backing field) */ showBoundingBox: boolean;
  53449. /**
  53450. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53451. */
  53452. showBoundingBox: boolean;
  53453. }
  53454. /**
  53455. * Component responsible of rendering the bounding box of the meshes in a scene.
  53456. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53457. */
  53458. export class BoundingBoxRenderer implements ISceneComponent {
  53459. /**
  53460. * The component name helpfull to identify the component in the list of scene components.
  53461. */
  53462. readonly name: string;
  53463. /**
  53464. * The scene the component belongs to.
  53465. */
  53466. scene: Scene;
  53467. /**
  53468. * Color of the bounding box lines placed in front of an object
  53469. */
  53470. frontColor: Color3;
  53471. /**
  53472. * Color of the bounding box lines placed behind an object
  53473. */
  53474. backColor: Color3;
  53475. /**
  53476. * Defines if the renderer should show the back lines or not
  53477. */
  53478. showBackLines: boolean;
  53479. /**
  53480. * @hidden
  53481. */
  53482. renderList: SmartArray<BoundingBox>;
  53483. private _colorShader;
  53484. private _vertexBuffers;
  53485. private _indexBuffer;
  53486. /**
  53487. * Instantiates a new bounding box renderer in a scene.
  53488. * @param scene the scene the renderer renders in
  53489. */
  53490. constructor(scene: Scene);
  53491. /**
  53492. * Registers the component in a given scene
  53493. */
  53494. register(): void;
  53495. private _evaluateSubMesh;
  53496. private _activeMesh;
  53497. private _prepareRessources;
  53498. private _createIndexBuffer;
  53499. /**
  53500. * Rebuilds the elements related to this component in case of
  53501. * context lost for instance.
  53502. */
  53503. rebuild(): void;
  53504. /**
  53505. * @hidden
  53506. */
  53507. reset(): void;
  53508. /**
  53509. * Render the bounding boxes of a specific rendering group
  53510. * @param renderingGroupId defines the rendering group to render
  53511. */
  53512. render(renderingGroupId: number): void;
  53513. /**
  53514. * In case of occlusion queries, we can render the occlusion bounding box through this method
  53515. * @param mesh Define the mesh to render the occlusion bounding box for
  53516. */
  53517. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  53518. /**
  53519. * Dispose and release the resources attached to this renderer.
  53520. */
  53521. dispose(): void;
  53522. }
  53523. }
  53524. declare module BABYLON {
  53525. /** @hidden */
  53526. export var depthPixelShader: {
  53527. name: string;
  53528. shader: string;
  53529. };
  53530. }
  53531. declare module BABYLON {
  53532. /**
  53533. * This represents a depth renderer in Babylon.
  53534. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53535. */
  53536. export class DepthRenderer {
  53537. private _scene;
  53538. private _depthMap;
  53539. private _effect;
  53540. private _cachedDefines;
  53541. private _camera;
  53542. /**
  53543. * Specifiess that the depth renderer will only be used within
  53544. * the camera it is created for.
  53545. * This can help forcing its rendering during the camera processing.
  53546. */
  53547. useOnlyInActiveCamera: boolean;
  53548. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  53549. /**
  53550. * Instantiates a depth renderer
  53551. * @param scene The scene the renderer belongs to
  53552. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53553. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  53554. */
  53555. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  53556. /**
  53557. * Creates the depth rendering effect and checks if the effect is ready.
  53558. * @param subMesh The submesh to be used to render the depth map of
  53559. * @param useInstances If multiple world instances should be used
  53560. * @returns if the depth renderer is ready to render the depth map
  53561. */
  53562. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53563. /**
  53564. * Gets the texture which the depth map will be written to.
  53565. * @returns The depth map texture
  53566. */
  53567. getDepthMap(): RenderTargetTexture;
  53568. /**
  53569. * Disposes of the depth renderer.
  53570. */
  53571. dispose(): void;
  53572. }
  53573. }
  53574. declare module BABYLON {
  53575. interface Scene {
  53576. /** @hidden (Backing field) */ depthRenderer: {
  53577. [id: string]: DepthRenderer;
  53578. };
  53579. /**
  53580. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  53581. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  53582. * @returns the created depth renderer
  53583. */
  53584. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  53585. /**
  53586. * Disables a depth renderer for a given camera
  53587. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  53588. */
  53589. disableDepthRenderer(camera?: Nullable<Camera>): void;
  53590. }
  53591. /**
  53592. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  53593. * in several rendering techniques.
  53594. */
  53595. export class DepthRendererSceneComponent implements ISceneComponent {
  53596. /**
  53597. * The component name helpfull to identify the component in the list of scene components.
  53598. */
  53599. readonly name: string;
  53600. /**
  53601. * The scene the component belongs to.
  53602. */
  53603. scene: Scene;
  53604. /**
  53605. * Creates a new instance of the component for the given scene
  53606. * @param scene Defines the scene to register the component in
  53607. */
  53608. constructor(scene: Scene);
  53609. /**
  53610. * Registers the component in a given scene
  53611. */
  53612. register(): void;
  53613. /**
  53614. * Rebuilds the elements related to this component in case of
  53615. * context lost for instance.
  53616. */
  53617. rebuild(): void;
  53618. /**
  53619. * Disposes the component and the associated ressources
  53620. */
  53621. dispose(): void;
  53622. private _gatherRenderTargets;
  53623. private _gatherActiveCameraRenderTargets;
  53624. }
  53625. }
  53626. declare module BABYLON {
  53627. /** @hidden */
  53628. export var outlinePixelShader: {
  53629. name: string;
  53630. shader: string;
  53631. };
  53632. }
  53633. declare module BABYLON {
  53634. /** @hidden */
  53635. export var outlineVertexShader: {
  53636. name: string;
  53637. shader: string;
  53638. };
  53639. }
  53640. declare module BABYLON {
  53641. interface Scene {
  53642. /** @hidden */ outlineRenderer: OutlineRenderer;
  53643. /**
  53644. * Gets the outline renderer associated with the scene
  53645. * @returns a OutlineRenderer
  53646. */
  53647. getOutlineRenderer(): OutlineRenderer;
  53648. }
  53649. interface AbstractMesh {
  53650. /** @hidden (Backing field) */ renderOutline: boolean;
  53651. /**
  53652. * Gets or sets a boolean indicating if the outline must be rendered as well
  53653. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  53654. */
  53655. renderOutline: boolean;
  53656. /** @hidden (Backing field) */ renderOverlay: boolean;
  53657. /**
  53658. * Gets or sets a boolean indicating if the overlay must be rendered as well
  53659. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  53660. */
  53661. renderOverlay: boolean;
  53662. }
  53663. /**
  53664. * This class is responsible to draw bothe outline/overlay of meshes.
  53665. * It should not be used directly but through the available method on mesh.
  53666. */
  53667. export class OutlineRenderer implements ISceneComponent {
  53668. /**
  53669. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  53670. */
  53671. private static _StencilReference;
  53672. /**
  53673. * The name of the component. Each component must have a unique name.
  53674. */
  53675. name: string;
  53676. /**
  53677. * The scene the component belongs to.
  53678. */
  53679. scene: Scene;
  53680. /**
  53681. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  53682. */
  53683. zOffset: number;
  53684. private _engine;
  53685. private _effect;
  53686. private _cachedDefines;
  53687. private _savedDepthWrite;
  53688. /**
  53689. * Instantiates a new outline renderer. (There could be only one per scene).
  53690. * @param scene Defines the scene it belongs to
  53691. */
  53692. constructor(scene: Scene);
  53693. /**
  53694. * Register the component to one instance of a scene.
  53695. */
  53696. register(): void;
  53697. /**
  53698. * Rebuilds the elements related to this component in case of
  53699. * context lost for instance.
  53700. */
  53701. rebuild(): void;
  53702. /**
  53703. * Disposes the component and the associated ressources.
  53704. */
  53705. dispose(): void;
  53706. /**
  53707. * Renders the outline in the canvas.
  53708. * @param subMesh Defines the sumesh to render
  53709. * @param batch Defines the batch of meshes in case of instances
  53710. * @param useOverlay Defines if the rendering is for the overlay or the outline
  53711. */
  53712. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  53713. /**
  53714. * Returns whether or not the outline renderer is ready for a given submesh.
  53715. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  53716. * @param subMesh Defines the submesh to check readyness for
  53717. * @param useInstances Defines wheter wee are trying to render instances or not
  53718. * @returns true if ready otherwise false
  53719. */
  53720. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53721. private _beforeRenderingMesh;
  53722. private _afterRenderingMesh;
  53723. }
  53724. }
  53725. declare module BABYLON {
  53726. /**
  53727. * Defines the list of states available for a task inside a AssetsManager
  53728. */
  53729. export enum AssetTaskState {
  53730. /**
  53731. * Initialization
  53732. */
  53733. INIT = 0,
  53734. /**
  53735. * Running
  53736. */
  53737. RUNNING = 1,
  53738. /**
  53739. * Done
  53740. */
  53741. DONE = 2,
  53742. /**
  53743. * Error
  53744. */
  53745. ERROR = 3
  53746. }
  53747. /**
  53748. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  53749. */
  53750. export abstract class AbstractAssetTask {
  53751. /**
  53752. * Task name
  53753. */ name: string;
  53754. /**
  53755. * Callback called when the task is successful
  53756. */
  53757. onSuccess: (task: any) => void;
  53758. /**
  53759. * Callback called when the task is not successful
  53760. */
  53761. onError: (task: any, message?: string, exception?: any) => void;
  53762. /**
  53763. * Creates a new AssetsManager
  53764. * @param name defines the name of the task
  53765. */
  53766. constructor(
  53767. /**
  53768. * Task name
  53769. */ name: string);
  53770. private _isCompleted;
  53771. private _taskState;
  53772. private _errorObject;
  53773. /**
  53774. * Get if the task is completed
  53775. */
  53776. readonly isCompleted: boolean;
  53777. /**
  53778. * Gets the current state of the task
  53779. */
  53780. readonly taskState: AssetTaskState;
  53781. /**
  53782. * Gets the current error object (if task is in error)
  53783. */
  53784. readonly errorObject: {
  53785. message?: string;
  53786. exception?: any;
  53787. };
  53788. /**
  53789. * Internal only
  53790. * @hidden
  53791. */ setErrorObject(message?: string, exception?: any): void;
  53792. /**
  53793. * Execute the current task
  53794. * @param scene defines the scene where you want your assets to be loaded
  53795. * @param onSuccess is a callback called when the task is successfully executed
  53796. * @param onError is a callback called if an error occurs
  53797. */
  53798. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53799. /**
  53800. * Execute the current task
  53801. * @param scene defines the scene where you want your assets to be loaded
  53802. * @param onSuccess is a callback called when the task is successfully executed
  53803. * @param onError is a callback called if an error occurs
  53804. */
  53805. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53806. /**
  53807. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  53808. * This can be used with failed tasks that have the reason for failure fixed.
  53809. */
  53810. reset(): void;
  53811. private onErrorCallback;
  53812. private onDoneCallback;
  53813. }
  53814. /**
  53815. * Define the interface used by progress events raised during assets loading
  53816. */
  53817. export interface IAssetsProgressEvent {
  53818. /**
  53819. * Defines the number of remaining tasks to process
  53820. */
  53821. remainingCount: number;
  53822. /**
  53823. * Defines the total number of tasks
  53824. */
  53825. totalCount: number;
  53826. /**
  53827. * Defines the task that was just processed
  53828. */
  53829. task: AbstractAssetTask;
  53830. }
  53831. /**
  53832. * Class used to share progress information about assets loading
  53833. */
  53834. export class AssetsProgressEvent implements IAssetsProgressEvent {
  53835. /**
  53836. * Defines the number of remaining tasks to process
  53837. */
  53838. remainingCount: number;
  53839. /**
  53840. * Defines the total number of tasks
  53841. */
  53842. totalCount: number;
  53843. /**
  53844. * Defines the task that was just processed
  53845. */
  53846. task: AbstractAssetTask;
  53847. /**
  53848. * Creates a AssetsProgressEvent
  53849. * @param remainingCount defines the number of remaining tasks to process
  53850. * @param totalCount defines the total number of tasks
  53851. * @param task defines the task that was just processed
  53852. */
  53853. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  53854. }
  53855. /**
  53856. * Define a task used by AssetsManager to load meshes
  53857. */
  53858. export class MeshAssetTask extends AbstractAssetTask {
  53859. /**
  53860. * Defines the name of the task
  53861. */
  53862. name: string;
  53863. /**
  53864. * Defines the list of mesh's names you want to load
  53865. */
  53866. meshesNames: any;
  53867. /**
  53868. * Defines the root url to use as a base to load your meshes and associated resources
  53869. */
  53870. rootUrl: string;
  53871. /**
  53872. * Defines the filename of the scene to load from
  53873. */
  53874. sceneFilename: string;
  53875. /**
  53876. * Gets the list of loaded meshes
  53877. */
  53878. loadedMeshes: Array<AbstractMesh>;
  53879. /**
  53880. * Gets the list of loaded particle systems
  53881. */
  53882. loadedParticleSystems: Array<IParticleSystem>;
  53883. /**
  53884. * Gets the list of loaded skeletons
  53885. */
  53886. loadedSkeletons: Array<Skeleton>;
  53887. /**
  53888. * Gets the list of loaded animation groups
  53889. */
  53890. loadedAnimationGroups: Array<AnimationGroup>;
  53891. /**
  53892. * Callback called when the task is successful
  53893. */
  53894. onSuccess: (task: MeshAssetTask) => void;
  53895. /**
  53896. * Callback called when the task is successful
  53897. */
  53898. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  53899. /**
  53900. * Creates a new MeshAssetTask
  53901. * @param name defines the name of the task
  53902. * @param meshesNames defines the list of mesh's names you want to load
  53903. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  53904. * @param sceneFilename defines the filename of the scene to load from
  53905. */
  53906. constructor(
  53907. /**
  53908. * Defines the name of the task
  53909. */
  53910. name: string,
  53911. /**
  53912. * Defines the list of mesh's names you want to load
  53913. */
  53914. meshesNames: any,
  53915. /**
  53916. * Defines the root url to use as a base to load your meshes and associated resources
  53917. */
  53918. rootUrl: string,
  53919. /**
  53920. * Defines the filename of the scene to load from
  53921. */
  53922. sceneFilename: string);
  53923. /**
  53924. * Execute the current task
  53925. * @param scene defines the scene where you want your assets to be loaded
  53926. * @param onSuccess is a callback called when the task is successfully executed
  53927. * @param onError is a callback called if an error occurs
  53928. */
  53929. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53930. }
  53931. /**
  53932. * Define a task used by AssetsManager to load text content
  53933. */
  53934. export class TextFileAssetTask extends AbstractAssetTask {
  53935. /**
  53936. * Defines the name of the task
  53937. */
  53938. name: string;
  53939. /**
  53940. * Defines the location of the file to load
  53941. */
  53942. url: string;
  53943. /**
  53944. * Gets the loaded text string
  53945. */
  53946. text: string;
  53947. /**
  53948. * Callback called when the task is successful
  53949. */
  53950. onSuccess: (task: TextFileAssetTask) => void;
  53951. /**
  53952. * Callback called when the task is successful
  53953. */
  53954. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  53955. /**
  53956. * Creates a new TextFileAssetTask object
  53957. * @param name defines the name of the task
  53958. * @param url defines the location of the file to load
  53959. */
  53960. constructor(
  53961. /**
  53962. * Defines the name of the task
  53963. */
  53964. name: string,
  53965. /**
  53966. * Defines the location of the file to load
  53967. */
  53968. url: string);
  53969. /**
  53970. * Execute the current task
  53971. * @param scene defines the scene where you want your assets to be loaded
  53972. * @param onSuccess is a callback called when the task is successfully executed
  53973. * @param onError is a callback called if an error occurs
  53974. */
  53975. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53976. }
  53977. /**
  53978. * Define a task used by AssetsManager to load binary data
  53979. */
  53980. export class BinaryFileAssetTask extends AbstractAssetTask {
  53981. /**
  53982. * Defines the name of the task
  53983. */
  53984. name: string;
  53985. /**
  53986. * Defines the location of the file to load
  53987. */
  53988. url: string;
  53989. /**
  53990. * Gets the lodaded data (as an array buffer)
  53991. */
  53992. data: ArrayBuffer;
  53993. /**
  53994. * Callback called when the task is successful
  53995. */
  53996. onSuccess: (task: BinaryFileAssetTask) => void;
  53997. /**
  53998. * Callback called when the task is successful
  53999. */
  54000. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54001. /**
  54002. * Creates a new BinaryFileAssetTask object
  54003. * @param name defines the name of the new task
  54004. * @param url defines the location of the file to load
  54005. */
  54006. constructor(
  54007. /**
  54008. * Defines the name of the task
  54009. */
  54010. name: string,
  54011. /**
  54012. * Defines the location of the file to load
  54013. */
  54014. url: string);
  54015. /**
  54016. * Execute the current task
  54017. * @param scene defines the scene where you want your assets to be loaded
  54018. * @param onSuccess is a callback called when the task is successfully executed
  54019. * @param onError is a callback called if an error occurs
  54020. */
  54021. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54022. }
  54023. /**
  54024. * Define a task used by AssetsManager to load images
  54025. */
  54026. export class ImageAssetTask extends AbstractAssetTask {
  54027. /**
  54028. * Defines the name of the task
  54029. */
  54030. name: string;
  54031. /**
  54032. * Defines the location of the image to load
  54033. */
  54034. url: string;
  54035. /**
  54036. * Gets the loaded images
  54037. */
  54038. image: HTMLImageElement;
  54039. /**
  54040. * Callback called when the task is successful
  54041. */
  54042. onSuccess: (task: ImageAssetTask) => void;
  54043. /**
  54044. * Callback called when the task is successful
  54045. */
  54046. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54047. /**
  54048. * Creates a new ImageAssetTask
  54049. * @param name defines the name of the task
  54050. * @param url defines the location of the image to load
  54051. */
  54052. constructor(
  54053. /**
  54054. * Defines the name of the task
  54055. */
  54056. name: string,
  54057. /**
  54058. * Defines the location of the image to load
  54059. */
  54060. url: string);
  54061. /**
  54062. * Execute the current task
  54063. * @param scene defines the scene where you want your assets to be loaded
  54064. * @param onSuccess is a callback called when the task is successfully executed
  54065. * @param onError is a callback called if an error occurs
  54066. */
  54067. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54068. }
  54069. /**
  54070. * Defines the interface used by texture loading tasks
  54071. */
  54072. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54073. /**
  54074. * Gets the loaded texture
  54075. */
  54076. texture: TEX;
  54077. }
  54078. /**
  54079. * Define a task used by AssetsManager to load 2D textures
  54080. */
  54081. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54082. /**
  54083. * Defines the name of the task
  54084. */
  54085. name: string;
  54086. /**
  54087. * Defines the location of the file to load
  54088. */
  54089. url: string;
  54090. /**
  54091. * Defines if mipmap should not be generated (default is false)
  54092. */
  54093. noMipmap?: boolean | undefined;
  54094. /**
  54095. * Defines if texture must be inverted on Y axis (default is false)
  54096. */
  54097. invertY?: boolean | undefined;
  54098. /**
  54099. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54100. */
  54101. samplingMode: number;
  54102. /**
  54103. * Gets the loaded texture
  54104. */
  54105. texture: Texture;
  54106. /**
  54107. * Callback called when the task is successful
  54108. */
  54109. onSuccess: (task: TextureAssetTask) => void;
  54110. /**
  54111. * Callback called when the task is successful
  54112. */
  54113. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54114. /**
  54115. * Creates a new TextureAssetTask object
  54116. * @param name defines the name of the task
  54117. * @param url defines the location of the file to load
  54118. * @param noMipmap defines if mipmap should not be generated (default is false)
  54119. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54120. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54121. */
  54122. constructor(
  54123. /**
  54124. * Defines the name of the task
  54125. */
  54126. name: string,
  54127. /**
  54128. * Defines the location of the file to load
  54129. */
  54130. url: string,
  54131. /**
  54132. * Defines if mipmap should not be generated (default is false)
  54133. */
  54134. noMipmap?: boolean | undefined,
  54135. /**
  54136. * Defines if texture must be inverted on Y axis (default is false)
  54137. */
  54138. invertY?: boolean | undefined,
  54139. /**
  54140. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54141. */
  54142. samplingMode?: number);
  54143. /**
  54144. * Execute the current task
  54145. * @param scene defines the scene where you want your assets to be loaded
  54146. * @param onSuccess is a callback called when the task is successfully executed
  54147. * @param onError is a callback called if an error occurs
  54148. */
  54149. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54150. }
  54151. /**
  54152. * Define a task used by AssetsManager to load cube textures
  54153. */
  54154. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54155. /**
  54156. * Defines the name of the task
  54157. */
  54158. name: string;
  54159. /**
  54160. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54161. */
  54162. url: string;
  54163. /**
  54164. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54165. */
  54166. extensions?: string[] | undefined;
  54167. /**
  54168. * Defines if mipmaps should not be generated (default is false)
  54169. */
  54170. noMipmap?: boolean | undefined;
  54171. /**
  54172. * Defines the explicit list of files (undefined by default)
  54173. */
  54174. files?: string[] | undefined;
  54175. /**
  54176. * Gets the loaded texture
  54177. */
  54178. texture: CubeTexture;
  54179. /**
  54180. * Callback called when the task is successful
  54181. */
  54182. onSuccess: (task: CubeTextureAssetTask) => void;
  54183. /**
  54184. * Callback called when the task is successful
  54185. */
  54186. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54187. /**
  54188. * Creates a new CubeTextureAssetTask
  54189. * @param name defines the name of the task
  54190. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54191. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54192. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54193. * @param files defines the explicit list of files (undefined by default)
  54194. */
  54195. constructor(
  54196. /**
  54197. * Defines the name of the task
  54198. */
  54199. name: string,
  54200. /**
  54201. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54202. */
  54203. url: string,
  54204. /**
  54205. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54206. */
  54207. extensions?: string[] | undefined,
  54208. /**
  54209. * Defines if mipmaps should not be generated (default is false)
  54210. */
  54211. noMipmap?: boolean | undefined,
  54212. /**
  54213. * Defines the explicit list of files (undefined by default)
  54214. */
  54215. files?: string[] | undefined);
  54216. /**
  54217. * Execute the current task
  54218. * @param scene defines the scene where you want your assets to be loaded
  54219. * @param onSuccess is a callback called when the task is successfully executed
  54220. * @param onError is a callback called if an error occurs
  54221. */
  54222. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54223. }
  54224. /**
  54225. * Define a task used by AssetsManager to load HDR cube textures
  54226. */
  54227. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54228. /**
  54229. * Defines the name of the task
  54230. */
  54231. name: string;
  54232. /**
  54233. * Defines the location of the file to load
  54234. */
  54235. url: string;
  54236. /**
  54237. * Defines the desired size (the more it increases the longer the generation will be)
  54238. */
  54239. size: number;
  54240. /**
  54241. * Defines if mipmaps should not be generated (default is false)
  54242. */
  54243. noMipmap: boolean;
  54244. /**
  54245. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54246. */
  54247. generateHarmonics: boolean;
  54248. /**
  54249. * 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)
  54250. */
  54251. gammaSpace: boolean;
  54252. /**
  54253. * Internal Use Only
  54254. */
  54255. reserved: boolean;
  54256. /**
  54257. * Gets the loaded texture
  54258. */
  54259. texture: HDRCubeTexture;
  54260. /**
  54261. * Callback called when the task is successful
  54262. */
  54263. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54264. /**
  54265. * Callback called when the task is successful
  54266. */
  54267. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54268. /**
  54269. * Creates a new HDRCubeTextureAssetTask object
  54270. * @param name defines the name of the task
  54271. * @param url defines the location of the file to load
  54272. * @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.
  54273. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54274. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54275. * @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)
  54276. * @param reserved Internal use only
  54277. */
  54278. constructor(
  54279. /**
  54280. * Defines the name of the task
  54281. */
  54282. name: string,
  54283. /**
  54284. * Defines the location of the file to load
  54285. */
  54286. url: string,
  54287. /**
  54288. * Defines the desired size (the more it increases the longer the generation will be)
  54289. */
  54290. size: number,
  54291. /**
  54292. * Defines if mipmaps should not be generated (default is false)
  54293. */
  54294. noMipmap?: boolean,
  54295. /**
  54296. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54297. */
  54298. generateHarmonics?: boolean,
  54299. /**
  54300. * 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)
  54301. */
  54302. gammaSpace?: boolean,
  54303. /**
  54304. * Internal Use Only
  54305. */
  54306. reserved?: boolean);
  54307. /**
  54308. * Execute the current task
  54309. * @param scene defines the scene where you want your assets to be loaded
  54310. * @param onSuccess is a callback called when the task is successfully executed
  54311. * @param onError is a callback called if an error occurs
  54312. */
  54313. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54314. }
  54315. /**
  54316. * Define a task used by AssetsManager to load Equirectangular cube textures
  54317. */
  54318. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  54319. /**
  54320. * Defines the name of the task
  54321. */
  54322. name: string;
  54323. /**
  54324. * Defines the location of the file to load
  54325. */
  54326. url: string;
  54327. /**
  54328. * Defines the desired size (the more it increases the longer the generation will be)
  54329. */
  54330. size: number;
  54331. /**
  54332. * Defines if mipmaps should not be generated (default is false)
  54333. */
  54334. noMipmap: boolean;
  54335. /**
  54336. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54337. * but the standard material would require them in Gamma space) (default is true)
  54338. */
  54339. gammaSpace: boolean;
  54340. /**
  54341. * Gets the loaded texture
  54342. */
  54343. texture: EquiRectangularCubeTexture;
  54344. /**
  54345. * Callback called when the task is successful
  54346. */
  54347. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  54348. /**
  54349. * Callback called when the task is successful
  54350. */
  54351. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  54352. /**
  54353. * Creates a new EquiRectangularCubeTextureAssetTask object
  54354. * @param name defines the name of the task
  54355. * @param url defines the location of the file to load
  54356. * @param size defines the desired size (the more it increases the longer the generation will be)
  54357. * If the size is omitted this implies you are using a preprocessed cubemap.
  54358. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54359. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  54360. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  54361. * (default is true)
  54362. */
  54363. constructor(
  54364. /**
  54365. * Defines the name of the task
  54366. */
  54367. name: string,
  54368. /**
  54369. * Defines the location of the file to load
  54370. */
  54371. url: string,
  54372. /**
  54373. * Defines the desired size (the more it increases the longer the generation will be)
  54374. */
  54375. size: number,
  54376. /**
  54377. * Defines if mipmaps should not be generated (default is false)
  54378. */
  54379. noMipmap?: boolean,
  54380. /**
  54381. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54382. * but the standard material would require them in Gamma space) (default is true)
  54383. */
  54384. gammaSpace?: boolean);
  54385. /**
  54386. * Execute the current task
  54387. * @param scene defines the scene where you want your assets to be loaded
  54388. * @param onSuccess is a callback called when the task is successfully executed
  54389. * @param onError is a callback called if an error occurs
  54390. */
  54391. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54392. }
  54393. /**
  54394. * This class can be used to easily import assets into a scene
  54395. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54396. */
  54397. export class AssetsManager {
  54398. private _scene;
  54399. private _isLoading;
  54400. protected _tasks: AbstractAssetTask[];
  54401. protected _waitingTasksCount: number;
  54402. protected _totalTasksCount: number;
  54403. /**
  54404. * Callback called when all tasks are processed
  54405. */
  54406. onFinish: (tasks: AbstractAssetTask[]) => void;
  54407. /**
  54408. * Callback called when a task is successful
  54409. */
  54410. onTaskSuccess: (task: AbstractAssetTask) => void;
  54411. /**
  54412. * Callback called when a task had an error
  54413. */
  54414. onTaskError: (task: AbstractAssetTask) => void;
  54415. /**
  54416. * Callback called when a task is done (whatever the result is)
  54417. */
  54418. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54419. /**
  54420. * Observable called when all tasks are processed
  54421. */
  54422. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54423. /**
  54424. * Observable called when a task had an error
  54425. */
  54426. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54427. /**
  54428. * Observable called when all tasks were executed
  54429. */
  54430. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54431. /**
  54432. * Observable called when a task is done (whatever the result is)
  54433. */
  54434. onProgressObservable: Observable<IAssetsProgressEvent>;
  54435. /**
  54436. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54437. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54438. */
  54439. useDefaultLoadingScreen: boolean;
  54440. /**
  54441. * Creates a new AssetsManager
  54442. * @param scene defines the scene to work on
  54443. */
  54444. constructor(scene: Scene);
  54445. /**
  54446. * Add a MeshAssetTask to the list of active tasks
  54447. * @param taskName defines the name of the new task
  54448. * @param meshesNames defines the name of meshes to load
  54449. * @param rootUrl defines the root url to use to locate files
  54450. * @param sceneFilename defines the filename of the scene file
  54451. * @returns a new MeshAssetTask object
  54452. */
  54453. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  54454. /**
  54455. * Add a TextFileAssetTask to the list of active tasks
  54456. * @param taskName defines the name of the new task
  54457. * @param url defines the url of the file to load
  54458. * @returns a new TextFileAssetTask object
  54459. */
  54460. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  54461. /**
  54462. * Add a BinaryFileAssetTask to the list of active tasks
  54463. * @param taskName defines the name of the new task
  54464. * @param url defines the url of the file to load
  54465. * @returns a new BinaryFileAssetTask object
  54466. */
  54467. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  54468. /**
  54469. * Add a ImageAssetTask to the list of active tasks
  54470. * @param taskName defines the name of the new task
  54471. * @param url defines the url of the file to load
  54472. * @returns a new ImageAssetTask object
  54473. */
  54474. addImageTask(taskName: string, url: string): ImageAssetTask;
  54475. /**
  54476. * Add a TextureAssetTask to the list of active tasks
  54477. * @param taskName defines the name of the new task
  54478. * @param url defines the url of the file to load
  54479. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54480. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  54481. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54482. * @returns a new TextureAssetTask object
  54483. */
  54484. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  54485. /**
  54486. * Add a CubeTextureAssetTask to the list of active tasks
  54487. * @param taskName defines the name of the new task
  54488. * @param url defines the url of the file to load
  54489. * @param extensions defines the extension to use to load the cube map (can be null)
  54490. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54491. * @param files defines the list of files to load (can be null)
  54492. * @returns a new CubeTextureAssetTask object
  54493. */
  54494. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  54495. /**
  54496. *
  54497. * Add a HDRCubeTextureAssetTask to the list of active tasks
  54498. * @param taskName defines the name of the new task
  54499. * @param url defines the url of the file to load
  54500. * @param size defines the size you want for the cubemap (can be null)
  54501. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54502. * @param generateHarmonics defines if you want to automatically generate (true by default)
  54503. * @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)
  54504. * @param reserved Internal use only
  54505. * @returns a new HDRCubeTextureAssetTask object
  54506. */
  54507. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  54508. /**
  54509. *
  54510. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  54511. * @param taskName defines the name of the new task
  54512. * @param url defines the url of the file to load
  54513. * @param size defines the size you want for the cubemap (can be null)
  54514. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54515. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54516. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54517. * @returns a new EquiRectangularCubeTextureAssetTask object
  54518. */
  54519. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  54520. /**
  54521. * Remove a task from the assets manager.
  54522. * @param task the task to remove
  54523. */
  54524. removeTask(task: AbstractAssetTask): void;
  54525. private _decreaseWaitingTasksCount;
  54526. private _runTask;
  54527. /**
  54528. * Reset the AssetsManager and remove all tasks
  54529. * @return the current instance of the AssetsManager
  54530. */
  54531. reset(): AssetsManager;
  54532. /**
  54533. * Start the loading process
  54534. * @return the current instance of the AssetsManager
  54535. */
  54536. load(): AssetsManager;
  54537. /**
  54538. * Start the loading process as an async operation
  54539. * @return a promise returning the list of failed tasks
  54540. */
  54541. loadAsync(): Promise<void>;
  54542. }
  54543. }
  54544. declare module BABYLON {
  54545. /**
  54546. * Wrapper class for promise with external resolve and reject.
  54547. */
  54548. export class Deferred<T> {
  54549. /**
  54550. * The promise associated with this deferred object.
  54551. */
  54552. readonly promise: Promise<T>;
  54553. private _resolve;
  54554. private _reject;
  54555. /**
  54556. * The resolve method of the promise associated with this deferred object.
  54557. */
  54558. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  54559. /**
  54560. * The reject method of the promise associated with this deferred object.
  54561. */
  54562. readonly reject: (reason?: any) => void;
  54563. /**
  54564. * Constructor for this deferred object.
  54565. */
  54566. constructor();
  54567. }
  54568. }
  54569. declare module BABYLON {
  54570. /**
  54571. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  54572. */
  54573. export class MeshExploder {
  54574. private _centerMesh;
  54575. private _meshes;
  54576. private _meshesOrigins;
  54577. private _toCenterVectors;
  54578. private _scaledDirection;
  54579. private _newPosition;
  54580. private _centerPosition;
  54581. /**
  54582. * Explodes meshes from a center mesh.
  54583. * @param meshes The meshes to explode.
  54584. * @param centerMesh The mesh to be center of explosion.
  54585. */
  54586. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  54587. private _setCenterMesh;
  54588. /**
  54589. * Get class name
  54590. * @returns "MeshExploder"
  54591. */
  54592. getClassName(): string;
  54593. /**
  54594. * "Exploded meshes"
  54595. * @returns Array of meshes with the centerMesh at index 0.
  54596. */
  54597. getMeshes(): Array<Mesh>;
  54598. /**
  54599. * Explodes meshes giving a specific direction
  54600. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  54601. */
  54602. explode(direction?: number): void;
  54603. }
  54604. }
  54605. declare module BABYLON {
  54606. /**
  54607. * Class used to help managing file picking and drag'n'drop
  54608. */
  54609. export class FilesInput {
  54610. /**
  54611. * List of files ready to be loaded
  54612. */
  54613. static readonly FilesToLoad: {
  54614. [key: string]: File;
  54615. };
  54616. /**
  54617. * Callback called when a file is processed
  54618. */
  54619. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  54620. private _engine;
  54621. private _currentScene;
  54622. private _sceneLoadedCallback;
  54623. private _progressCallback;
  54624. private _additionalRenderLoopLogicCallback;
  54625. private _textureLoadingCallback;
  54626. private _startingProcessingFilesCallback;
  54627. private _onReloadCallback;
  54628. private _errorCallback;
  54629. private _elementToMonitor;
  54630. private _sceneFileToLoad;
  54631. private _filesToLoad;
  54632. /**
  54633. * Creates a new FilesInput
  54634. * @param engine defines the rendering engine
  54635. * @param scene defines the hosting scene
  54636. * @param sceneLoadedCallback callback called when scene is loaded
  54637. * @param progressCallback callback called to track progress
  54638. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  54639. * @param textureLoadingCallback callback called when a texture is loading
  54640. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  54641. * @param onReloadCallback callback called when a reload is requested
  54642. * @param errorCallback callback call if an error occurs
  54643. */
  54644. 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);
  54645. private _dragEnterHandler;
  54646. private _dragOverHandler;
  54647. private _dropHandler;
  54648. /**
  54649. * Calls this function to listen to drag'n'drop events on a specific DOM element
  54650. * @param elementToMonitor defines the DOM element to track
  54651. */
  54652. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  54653. /**
  54654. * Release all associated resources
  54655. */
  54656. dispose(): void;
  54657. private renderFunction;
  54658. private drag;
  54659. private drop;
  54660. private _traverseFolder;
  54661. private _processFiles;
  54662. /**
  54663. * Load files from a drop event
  54664. * @param event defines the drop event to use as source
  54665. */
  54666. loadFiles(event: any): void;
  54667. private _processReload;
  54668. /**
  54669. * Reload the current scene from the loaded files
  54670. */
  54671. reload(): void;
  54672. }
  54673. }
  54674. declare module BABYLON {
  54675. /**
  54676. * Defines the root class used to create scene optimization to use with SceneOptimizer
  54677. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54678. */
  54679. export class SceneOptimization {
  54680. /**
  54681. * Defines the priority of this optimization (0 by default which means first in the list)
  54682. */
  54683. priority: number;
  54684. /**
  54685. * Gets a string describing the action executed by the current optimization
  54686. * @returns description string
  54687. */
  54688. getDescription(): string;
  54689. /**
  54690. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54691. * @param scene defines the current scene where to apply this optimization
  54692. * @param optimizer defines the current optimizer
  54693. * @returns true if everything that can be done was applied
  54694. */
  54695. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54696. /**
  54697. * Creates the SceneOptimization object
  54698. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54699. * @param desc defines the description associated with the optimization
  54700. */
  54701. constructor(
  54702. /**
  54703. * Defines the priority of this optimization (0 by default which means first in the list)
  54704. */
  54705. priority?: number);
  54706. }
  54707. /**
  54708. * Defines an optimization used to reduce the size of render target textures
  54709. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54710. */
  54711. export class TextureOptimization extends SceneOptimization {
  54712. /**
  54713. * Defines the priority of this optimization (0 by default which means first in the list)
  54714. */
  54715. priority: number;
  54716. /**
  54717. * 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
  54718. */
  54719. maximumSize: number;
  54720. /**
  54721. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54722. */
  54723. step: number;
  54724. /**
  54725. * Gets a string describing the action executed by the current optimization
  54726. * @returns description string
  54727. */
  54728. getDescription(): string;
  54729. /**
  54730. * Creates the TextureOptimization object
  54731. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54732. * @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
  54733. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54734. */
  54735. constructor(
  54736. /**
  54737. * Defines the priority of this optimization (0 by default which means first in the list)
  54738. */
  54739. priority?: number,
  54740. /**
  54741. * 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
  54742. */
  54743. maximumSize?: number,
  54744. /**
  54745. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54746. */
  54747. step?: number);
  54748. /**
  54749. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54750. * @param scene defines the current scene where to apply this optimization
  54751. * @param optimizer defines the current optimizer
  54752. * @returns true if everything that can be done was applied
  54753. */
  54754. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54755. }
  54756. /**
  54757. * Defines an optimization used to increase or decrease the rendering resolution
  54758. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54759. */
  54760. export class HardwareScalingOptimization extends SceneOptimization {
  54761. /**
  54762. * Defines the priority of this optimization (0 by default which means first in the list)
  54763. */
  54764. priority: number;
  54765. /**
  54766. * Defines the maximum scale to use (2 by default)
  54767. */
  54768. maximumScale: number;
  54769. /**
  54770. * Defines the step to use between two passes (0.5 by default)
  54771. */
  54772. step: number;
  54773. private _currentScale;
  54774. private _directionOffset;
  54775. /**
  54776. * Gets a string describing the action executed by the current optimization
  54777. * @return description string
  54778. */
  54779. getDescription(): string;
  54780. /**
  54781. * Creates the HardwareScalingOptimization object
  54782. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54783. * @param maximumScale defines the maximum scale to use (2 by default)
  54784. * @param step defines the step to use between two passes (0.5 by default)
  54785. */
  54786. constructor(
  54787. /**
  54788. * Defines the priority of this optimization (0 by default which means first in the list)
  54789. */
  54790. priority?: number,
  54791. /**
  54792. * Defines the maximum scale to use (2 by default)
  54793. */
  54794. maximumScale?: number,
  54795. /**
  54796. * Defines the step to use between two passes (0.5 by default)
  54797. */
  54798. step?: number);
  54799. /**
  54800. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54801. * @param scene defines the current scene where to apply this optimization
  54802. * @param optimizer defines the current optimizer
  54803. * @returns true if everything that can be done was applied
  54804. */
  54805. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54806. }
  54807. /**
  54808. * Defines an optimization used to remove shadows
  54809. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54810. */
  54811. export class ShadowsOptimization extends SceneOptimization {
  54812. /**
  54813. * Gets a string describing the action executed by the current optimization
  54814. * @return description string
  54815. */
  54816. getDescription(): string;
  54817. /**
  54818. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54819. * @param scene defines the current scene where to apply this optimization
  54820. * @param optimizer defines the current optimizer
  54821. * @returns true if everything that can be done was applied
  54822. */
  54823. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54824. }
  54825. /**
  54826. * Defines an optimization used to turn post-processes off
  54827. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54828. */
  54829. export class PostProcessesOptimization extends SceneOptimization {
  54830. /**
  54831. * Gets a string describing the action executed by the current optimization
  54832. * @return description string
  54833. */
  54834. getDescription(): string;
  54835. /**
  54836. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54837. * @param scene defines the current scene where to apply this optimization
  54838. * @param optimizer defines the current optimizer
  54839. * @returns true if everything that can be done was applied
  54840. */
  54841. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54842. }
  54843. /**
  54844. * Defines an optimization used to turn lens flares off
  54845. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54846. */
  54847. export class LensFlaresOptimization extends SceneOptimization {
  54848. /**
  54849. * Gets a string describing the action executed by the current optimization
  54850. * @return description string
  54851. */
  54852. getDescription(): string;
  54853. /**
  54854. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54855. * @param scene defines the current scene where to apply this optimization
  54856. * @param optimizer defines the current optimizer
  54857. * @returns true if everything that can be done was applied
  54858. */
  54859. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54860. }
  54861. /**
  54862. * Defines an optimization based on user defined callback.
  54863. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54864. */
  54865. export class CustomOptimization extends SceneOptimization {
  54866. /**
  54867. * Callback called to apply the custom optimization.
  54868. */
  54869. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  54870. /**
  54871. * Callback called to get custom description
  54872. */
  54873. onGetDescription: () => string;
  54874. /**
  54875. * Gets a string describing the action executed by the current optimization
  54876. * @returns description string
  54877. */
  54878. getDescription(): string;
  54879. /**
  54880. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54881. * @param scene defines the current scene where to apply this optimization
  54882. * @param optimizer defines the current optimizer
  54883. * @returns true if everything that can be done was applied
  54884. */
  54885. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54886. }
  54887. /**
  54888. * Defines an optimization used to turn particles off
  54889. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54890. */
  54891. export class ParticlesOptimization extends SceneOptimization {
  54892. /**
  54893. * Gets a string describing the action executed by the current optimization
  54894. * @return description string
  54895. */
  54896. getDescription(): string;
  54897. /**
  54898. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54899. * @param scene defines the current scene where to apply this optimization
  54900. * @param optimizer defines the current optimizer
  54901. * @returns true if everything that can be done was applied
  54902. */
  54903. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54904. }
  54905. /**
  54906. * Defines an optimization used to turn render targets off
  54907. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54908. */
  54909. export class RenderTargetsOptimization extends SceneOptimization {
  54910. /**
  54911. * Gets a string describing the action executed by the current optimization
  54912. * @return description string
  54913. */
  54914. getDescription(): string;
  54915. /**
  54916. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54917. * @param scene defines the current scene where to apply this optimization
  54918. * @param optimizer defines the current optimizer
  54919. * @returns true if everything that can be done was applied
  54920. */
  54921. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54922. }
  54923. /**
  54924. * Defines an optimization used to merge meshes with compatible materials
  54925. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54926. */
  54927. export class MergeMeshesOptimization extends SceneOptimization {
  54928. private static _UpdateSelectionTree;
  54929. /**
  54930. * Gets or sets a boolean which defines if optimization octree has to be updated
  54931. */
  54932. /**
  54933. * Gets or sets a boolean which defines if optimization octree has to be updated
  54934. */
  54935. static UpdateSelectionTree: boolean;
  54936. /**
  54937. * Gets a string describing the action executed by the current optimization
  54938. * @return description string
  54939. */
  54940. getDescription(): string;
  54941. private _canBeMerged;
  54942. /**
  54943. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54944. * @param scene defines the current scene where to apply this optimization
  54945. * @param optimizer defines the current optimizer
  54946. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  54947. * @returns true if everything that can be done was applied
  54948. */
  54949. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  54950. }
  54951. /**
  54952. * Defines a list of options used by SceneOptimizer
  54953. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54954. */
  54955. export class SceneOptimizerOptions {
  54956. /**
  54957. * Defines the target frame rate to reach (60 by default)
  54958. */
  54959. targetFrameRate: number;
  54960. /**
  54961. * Defines the interval between two checkes (2000ms by default)
  54962. */
  54963. trackerDuration: number;
  54964. /**
  54965. * Gets the list of optimizations to apply
  54966. */
  54967. optimizations: SceneOptimization[];
  54968. /**
  54969. * Creates a new list of options used by SceneOptimizer
  54970. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  54971. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  54972. */
  54973. constructor(
  54974. /**
  54975. * Defines the target frame rate to reach (60 by default)
  54976. */
  54977. targetFrameRate?: number,
  54978. /**
  54979. * Defines the interval between two checkes (2000ms by default)
  54980. */
  54981. trackerDuration?: number);
  54982. /**
  54983. * Add a new optimization
  54984. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  54985. * @returns the current SceneOptimizerOptions
  54986. */
  54987. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  54988. /**
  54989. * Add a new custom optimization
  54990. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  54991. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  54992. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54993. * @returns the current SceneOptimizerOptions
  54994. */
  54995. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  54996. /**
  54997. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  54998. * @param targetFrameRate defines the target frame rate (60 by default)
  54999. * @returns a SceneOptimizerOptions object
  55000. */
  55001. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55002. /**
  55003. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55004. * @param targetFrameRate defines the target frame rate (60 by default)
  55005. * @returns a SceneOptimizerOptions object
  55006. */
  55007. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55008. /**
  55009. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55010. * @param targetFrameRate defines the target frame rate (60 by default)
  55011. * @returns a SceneOptimizerOptions object
  55012. */
  55013. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55014. }
  55015. /**
  55016. * Class used to run optimizations in order to reach a target frame rate
  55017. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55018. */
  55019. export class SceneOptimizer implements IDisposable {
  55020. private _isRunning;
  55021. private _options;
  55022. private _scene;
  55023. private _currentPriorityLevel;
  55024. private _targetFrameRate;
  55025. private _trackerDuration;
  55026. private _currentFrameRate;
  55027. private _sceneDisposeObserver;
  55028. private _improvementMode;
  55029. /**
  55030. * Defines an observable called when the optimizer reaches the target frame rate
  55031. */
  55032. onSuccessObservable: Observable<SceneOptimizer>;
  55033. /**
  55034. * Defines an observable called when the optimizer enables an optimization
  55035. */
  55036. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55037. /**
  55038. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55039. */
  55040. onFailureObservable: Observable<SceneOptimizer>;
  55041. /**
  55042. * Gets a boolean indicating if the optimizer is in improvement mode
  55043. */
  55044. readonly isInImprovementMode: boolean;
  55045. /**
  55046. * Gets the current priority level (0 at start)
  55047. */
  55048. readonly currentPriorityLevel: number;
  55049. /**
  55050. * Gets the current frame rate checked by the SceneOptimizer
  55051. */
  55052. readonly currentFrameRate: number;
  55053. /**
  55054. * Gets or sets the current target frame rate (60 by default)
  55055. */
  55056. /**
  55057. * Gets or sets the current target frame rate (60 by default)
  55058. */
  55059. targetFrameRate: number;
  55060. /**
  55061. * Gets or sets the current interval between two checks (every 2000ms by default)
  55062. */
  55063. /**
  55064. * Gets or sets the current interval between two checks (every 2000ms by default)
  55065. */
  55066. trackerDuration: number;
  55067. /**
  55068. * Gets the list of active optimizations
  55069. */
  55070. readonly optimizations: SceneOptimization[];
  55071. /**
  55072. * Creates a new SceneOptimizer
  55073. * @param scene defines the scene to work on
  55074. * @param options defines the options to use with the SceneOptimizer
  55075. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55076. * @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)
  55077. */
  55078. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55079. /**
  55080. * Stops the current optimizer
  55081. */
  55082. stop(): void;
  55083. /**
  55084. * Reset the optimizer to initial step (current priority level = 0)
  55085. */
  55086. reset(): void;
  55087. /**
  55088. * Start the optimizer. By default it will try to reach a specific framerate
  55089. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55090. */
  55091. start(): void;
  55092. private _checkCurrentState;
  55093. /**
  55094. * Release all resources
  55095. */
  55096. dispose(): void;
  55097. /**
  55098. * Helper function to create a SceneOptimizer with one single line of code
  55099. * @param scene defines the scene to work on
  55100. * @param options defines the options to use with the SceneOptimizer
  55101. * @param onSuccess defines a callback to call on success
  55102. * @param onFailure defines a callback to call on failure
  55103. * @returns the new SceneOptimizer object
  55104. */
  55105. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55106. }
  55107. }
  55108. declare module BABYLON {
  55109. /**
  55110. * Class used to serialize a scene into a string
  55111. */
  55112. export class SceneSerializer {
  55113. /**
  55114. * Clear cache used by a previous serialization
  55115. */
  55116. static ClearCache(): void;
  55117. /**
  55118. * Serialize a scene into a JSON compatible object
  55119. * @param scene defines the scene to serialize
  55120. * @returns a JSON compatible object
  55121. */
  55122. static Serialize(scene: Scene): any;
  55123. /**
  55124. * Serialize a mesh into a JSON compatible object
  55125. * @param toSerialize defines the mesh to serialize
  55126. * @param withParents defines if parents must be serialized as well
  55127. * @param withChildren defines if children must be serialized as well
  55128. * @returns a JSON compatible object
  55129. */
  55130. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55131. }
  55132. }
  55133. declare module BABYLON {
  55134. /**
  55135. * Class used to host texture specific utilities
  55136. */
  55137. export class TextureTools {
  55138. /**
  55139. * Uses the GPU to create a copy texture rescaled at a given size
  55140. * @param texture Texture to copy from
  55141. * @param width defines the desired width
  55142. * @param height defines the desired height
  55143. * @param useBilinearMode defines if bilinear mode has to be used
  55144. * @return the generated texture
  55145. */
  55146. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  55147. }
  55148. }
  55149. declare module BABYLON {
  55150. /**
  55151. * This represents the different options avilable for the video capture.
  55152. */
  55153. export interface VideoRecorderOptions {
  55154. /** Defines the mime type of the video */
  55155. mimeType: string;
  55156. /** Defines the video the video should be recorded at */
  55157. fps: number;
  55158. /** Defines the chunk size for the recording data */
  55159. recordChunckSize: number;
  55160. /** The audio tracks to attach to the record */
  55161. audioTracks?: MediaStreamTrack[];
  55162. }
  55163. /**
  55164. * This can helps recording videos from BabylonJS.
  55165. * This is based on the available WebRTC functionalities of the browser.
  55166. *
  55167. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55168. */
  55169. export class VideoRecorder {
  55170. private static readonly _defaultOptions;
  55171. /**
  55172. * Returns wehther or not the VideoRecorder is available in your browser.
  55173. * @param engine Defines the Babylon Engine to check the support for
  55174. * @returns true if supported otherwise false
  55175. */
  55176. static IsSupported(engine: Engine): boolean;
  55177. private readonly _options;
  55178. private _canvas;
  55179. private _mediaRecorder;
  55180. private _recordedChunks;
  55181. private _fileName;
  55182. private _resolve;
  55183. private _reject;
  55184. /**
  55185. * True wether a recording is already in progress.
  55186. */
  55187. readonly isRecording: boolean;
  55188. /**
  55189. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55190. * a video file.
  55191. * @param engine Defines the BabylonJS Engine you wish to record
  55192. * @param options Defines options that can be used to customized the capture
  55193. */
  55194. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55195. /**
  55196. * Stops the current recording before the default capture timeout passed in the startRecording
  55197. * functions.
  55198. */
  55199. stopRecording(): void;
  55200. /**
  55201. * Starts recording the canvas for a max duration specified in parameters.
  55202. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  55203. * @param maxDuration Defines the maximum recording time in seconds.
  55204. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55205. * @return a promise callback at the end of the recording with the video data in Blob.
  55206. */
  55207. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55208. /**
  55209. * Releases internal resources used during the recording.
  55210. */
  55211. dispose(): void;
  55212. private _handleDataAvailable;
  55213. private _handleError;
  55214. private _handleStop;
  55215. }
  55216. }
  55217. declare module BABYLON {
  55218. /**
  55219. * Helper class to push actions to a pool of workers.
  55220. */
  55221. export class WorkerPool implements IDisposable {
  55222. private _workerInfos;
  55223. private _pendingActions;
  55224. /**
  55225. * Constructor
  55226. * @param workers Array of workers to use for actions
  55227. */
  55228. constructor(workers: Array<Worker>);
  55229. /**
  55230. * Terminates all workers and clears any pending actions.
  55231. */
  55232. dispose(): void;
  55233. /**
  55234. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55235. * pended until a worker has completed its action.
  55236. * @param action The action to perform. Call onComplete when the action is complete.
  55237. */
  55238. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55239. private _execute;
  55240. }
  55241. }
  55242. declare module BABYLON {
  55243. /**
  55244. * Class containing a set of static utilities functions for screenshots
  55245. */
  55246. export class ScreenshotTools {
  55247. /**
  55248. * Captures a screenshot of the current rendering
  55249. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55250. * @param engine defines the rendering engine
  55251. * @param camera defines the source camera
  55252. * @param size This parameter can be set to a single number or to an object with the
  55253. * following (optional) properties: precision, width, height. If a single number is passed,
  55254. * it will be used for both width and height. If an object is passed, the screenshot size
  55255. * will be derived from the parameters. The precision property is a multiplier allowing
  55256. * rendering at a higher or lower resolution
  55257. * @param successCallback defines the callback receives a single parameter which contains the
  55258. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55259. * src parameter of an <img> to display it
  55260. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55261. * Check your browser for supported MIME types
  55262. */
  55263. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55264. /**
  55265. * Generates an image screenshot from the specified camera.
  55266. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55267. * @param engine The engine to use for rendering
  55268. * @param camera The camera to use for rendering
  55269. * @param size This parameter can be set to a single number or to an object with the
  55270. * following (optional) properties: precision, width, height. If a single number is passed,
  55271. * it will be used for both width and height. If an object is passed, the screenshot size
  55272. * will be derived from the parameters. The precision property is a multiplier allowing
  55273. * rendering at a higher or lower resolution
  55274. * @param successCallback The callback receives a single parameter which contains the
  55275. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55276. * src parameter of an <img> to display it
  55277. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55278. * Check your browser for supported MIME types
  55279. * @param samples Texture samples (default: 1)
  55280. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55281. * @param fileName A name for for the downloaded file.
  55282. */
  55283. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55284. }
  55285. }
  55286. declare module BABYLON {
  55287. /**
  55288. * A cursor which tracks a point on a path
  55289. */
  55290. export class PathCursor {
  55291. private path;
  55292. /**
  55293. * Stores path cursor callbacks for when an onchange event is triggered
  55294. */
  55295. private _onchange;
  55296. /**
  55297. * The value of the path cursor
  55298. */
  55299. value: number;
  55300. /**
  55301. * The animation array of the path cursor
  55302. */
  55303. animations: Animation[];
  55304. /**
  55305. * Initializes the path cursor
  55306. * @param path The path to track
  55307. */
  55308. constructor(path: Path2);
  55309. /**
  55310. * Gets the cursor point on the path
  55311. * @returns A point on the path cursor at the cursor location
  55312. */
  55313. getPoint(): Vector3;
  55314. /**
  55315. * Moves the cursor ahead by the step amount
  55316. * @param step The amount to move the cursor forward
  55317. * @returns This path cursor
  55318. */
  55319. moveAhead(step?: number): PathCursor;
  55320. /**
  55321. * Moves the cursor behind by the step amount
  55322. * @param step The amount to move the cursor back
  55323. * @returns This path cursor
  55324. */
  55325. moveBack(step?: number): PathCursor;
  55326. /**
  55327. * Moves the cursor by the step amount
  55328. * If the step amount is greater than one, an exception is thrown
  55329. * @param step The amount to move the cursor
  55330. * @returns This path cursor
  55331. */
  55332. move(step: number): PathCursor;
  55333. /**
  55334. * Ensures that the value is limited between zero and one
  55335. * @returns This path cursor
  55336. */
  55337. private ensureLimits;
  55338. /**
  55339. * Runs onchange callbacks on change (used by the animation engine)
  55340. * @returns This path cursor
  55341. */
  55342. private raiseOnChange;
  55343. /**
  55344. * Executes a function on change
  55345. * @param f A path cursor onchange callback
  55346. * @returns This path cursor
  55347. */
  55348. onchange(f: (cursor: PathCursor) => void): PathCursor;
  55349. }
  55350. }
  55351. declare module BABYLON {
  55352. /** @hidden */
  55353. export var blurPixelShader: {
  55354. name: string;
  55355. shader: string;
  55356. };
  55357. }
  55358. declare module BABYLON {
  55359. /** @hidden */
  55360. export var bones300Declaration: {
  55361. name: string;
  55362. shader: string;
  55363. };
  55364. }
  55365. declare module BABYLON {
  55366. /** @hidden */
  55367. export var instances300Declaration: {
  55368. name: string;
  55369. shader: string;
  55370. };
  55371. }
  55372. declare module BABYLON {
  55373. /** @hidden */
  55374. export var pointCloudVertexDeclaration: {
  55375. name: string;
  55376. shader: string;
  55377. };
  55378. }
  55379. // Mixins
  55380. interface Window {
  55381. mozIndexedDB: IDBFactory;
  55382. webkitIndexedDB: IDBFactory;
  55383. msIndexedDB: IDBFactory;
  55384. webkitURL: typeof URL;
  55385. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55386. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55387. WebGLRenderingContext: WebGLRenderingContext;
  55388. MSGesture: MSGesture;
  55389. CANNON: any;
  55390. AudioContext: AudioContext;
  55391. webkitAudioContext: AudioContext;
  55392. PointerEvent: any;
  55393. Math: Math;
  55394. Uint8Array: Uint8ArrayConstructor;
  55395. Float32Array: Float32ArrayConstructor;
  55396. mozURL: typeof URL;
  55397. msURL: typeof URL;
  55398. VRFrameData: any; // WebVR, from specs 1.1
  55399. DracoDecoderModule: any;
  55400. setImmediate(handler: (...args: any[]) => void): number;
  55401. }
  55402. interface HTMLCanvasElement {
  55403. requestPointerLock(): void;
  55404. msRequestPointerLock?(): void;
  55405. mozRequestPointerLock?(): void;
  55406. webkitRequestPointerLock?(): void;
  55407. /** Track wether a record is in progress */
  55408. isRecording: boolean;
  55409. /** Capture Stream method defined by some browsers */
  55410. captureStream(fps?: number): MediaStream;
  55411. }
  55412. interface CanvasRenderingContext2D {
  55413. msImageSmoothingEnabled: boolean;
  55414. }
  55415. interface MouseEvent {
  55416. mozMovementX: number;
  55417. mozMovementY: number;
  55418. webkitMovementX: number;
  55419. webkitMovementY: number;
  55420. msMovementX: number;
  55421. msMovementY: number;
  55422. }
  55423. interface Navigator {
  55424. mozGetVRDevices: (any: any) => any;
  55425. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55426. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55427. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55428. webkitGetGamepads(): Gamepad[];
  55429. msGetGamepads(): Gamepad[];
  55430. webkitGamepads(): Gamepad[];
  55431. }
  55432. interface HTMLVideoElement {
  55433. mozSrcObject: any;
  55434. }
  55435. interface Math {
  55436. fround(x: number): number;
  55437. imul(a: number, b: number): number;
  55438. }
  55439. interface WebGLProgram {
  55440. context?: WebGLRenderingContext;
  55441. vertexShader?: WebGLShader;
  55442. fragmentShader?: WebGLShader;
  55443. isParallelCompiled: boolean;
  55444. onCompiled?: () => void;
  55445. }
  55446. interface WebGLRenderingContext {
  55447. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  55448. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  55449. vertexAttribDivisor(index: number, divisor: number): void;
  55450. createVertexArray(): any;
  55451. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  55452. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  55453. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  55454. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  55455. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  55456. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  55457. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  55458. // Queries
  55459. createQuery(): WebGLQuery;
  55460. deleteQuery(query: WebGLQuery): void;
  55461. beginQuery(target: number, query: WebGLQuery): void;
  55462. endQuery(target: number): void;
  55463. getQueryParameter(query: WebGLQuery, pname: number): any;
  55464. getQuery(target: number, pname: number): any;
  55465. MAX_SAMPLES: number;
  55466. RGBA8: number;
  55467. READ_FRAMEBUFFER: number;
  55468. DRAW_FRAMEBUFFER: number;
  55469. UNIFORM_BUFFER: number;
  55470. HALF_FLOAT_OES: number;
  55471. RGBA16F: number;
  55472. RGBA32F: number;
  55473. R32F: number;
  55474. RG32F: number;
  55475. RGB32F: number;
  55476. R16F: number;
  55477. RG16F: number;
  55478. RGB16F: number;
  55479. RED: number;
  55480. RG: number;
  55481. R8: number;
  55482. RG8: number;
  55483. UNSIGNED_INT_24_8: number;
  55484. DEPTH24_STENCIL8: number;
  55485. /* Multiple Render Targets */
  55486. drawBuffers(buffers: number[]): void;
  55487. readBuffer(src: number): void;
  55488. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  55489. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  55490. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  55491. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  55492. // Occlusion Query
  55493. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  55494. ANY_SAMPLES_PASSED: number;
  55495. QUERY_RESULT_AVAILABLE: number;
  55496. QUERY_RESULT: number;
  55497. }
  55498. interface WebGLBuffer {
  55499. references: number;
  55500. capacity: number;
  55501. is32Bits: boolean;
  55502. }
  55503. interface WebGLProgram {
  55504. transformFeedback?: WebGLTransformFeedback | null; private _SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  55505. }
  55506. interface EXT_disjoint_timer_query {
  55507. QUERY_COUNTER_BITS_EXT: number;
  55508. TIME_ELAPSED_EXT: number;
  55509. TIMESTAMP_EXT: number;
  55510. GPU_DISJOINT_EXT: number;
  55511. QUERY_RESULT_EXT: number;
  55512. QUERY_RESULT_AVAILABLE_EXT: number;
  55513. queryCounterEXT(query: WebGLQuery, target: number): void;
  55514. createQueryEXT(): WebGLQuery;
  55515. beginQueryEXT(target: number, query: WebGLQuery): void;
  55516. endQueryEXT(target: number): void;
  55517. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  55518. deleteQueryEXT(query: WebGLQuery): void;
  55519. }
  55520. interface WebGLUniformLocation { currentState: any;
  55521. }
  55522. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  55523. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  55524. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  55525. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55526. interface WebGLRenderingContext {
  55527. readonly RASTERIZER_DISCARD: number;
  55528. readonly DEPTH_COMPONENT24: number;
  55529. readonly TEXTURE_3D: number;
  55530. readonly TEXTURE_2D_ARRAY: number;
  55531. readonly TEXTURE_COMPARE_FUNC: number;
  55532. readonly TEXTURE_COMPARE_MODE: number;
  55533. readonly COMPARE_REF_TO_TEXTURE: number;
  55534. readonly TEXTURE_WRAP_R: number;
  55535. readonly HALF_FLOAT: number;
  55536. readonly RGB8: number;
  55537. readonly RED_INTEGER: number;
  55538. readonly RG_INTEGER: number;
  55539. readonly RGB_INTEGER: number;
  55540. readonly RGBA_INTEGER: number;
  55541. readonly R8_SNORM: number;
  55542. readonly RG8_SNORM: number;
  55543. readonly RGB8_SNORM: number;
  55544. readonly RGBA8_SNORM: number;
  55545. readonly R8I: number;
  55546. readonly RG8I: number;
  55547. readonly RGB8I: number;
  55548. readonly RGBA8I: number;
  55549. readonly R8UI: number;
  55550. readonly RG8UI: number;
  55551. readonly RGB8UI: number;
  55552. readonly RGBA8UI: number;
  55553. readonly R16I: number;
  55554. readonly RG16I: number;
  55555. readonly RGB16I: number;
  55556. readonly RGBA16I: number;
  55557. readonly R16UI: number;
  55558. readonly RG16UI: number;
  55559. readonly RGB16UI: number;
  55560. readonly RGBA16UI: number;
  55561. readonly R32I: number;
  55562. readonly RG32I: number;
  55563. readonly RGB32I: number;
  55564. readonly RGBA32I: number;
  55565. readonly R32UI: number;
  55566. readonly RG32UI: number;
  55567. readonly RGB32UI: number;
  55568. readonly RGBA32UI: number;
  55569. readonly RGB10_A2UI: number;
  55570. readonly R11F_G11F_B10F: number;
  55571. readonly RGB9_E5: number;
  55572. readonly RGB10_A2: number;
  55573. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  55574. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  55575. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  55576. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  55577. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  55578. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  55579. 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;
  55580. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  55581. readonly TRANSFORM_FEEDBACK: number;
  55582. readonly INTERLEAVED_ATTRIBS: number;
  55583. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  55584. createTransformFeedback(): WebGLTransformFeedback;
  55585. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  55586. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  55587. beginTransformFeedback(primitiveMode: number): void;
  55588. endTransformFeedback(): void;
  55589. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  55590. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55591. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55592. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55593. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  55594. }
  55595. interface ImageBitmap {
  55596. readonly width: number;
  55597. readonly height: number;
  55598. close(): void;
  55599. }
  55600. interface WebGLQuery extends WebGLObject {
  55601. }
  55602. declare var WebGLQuery: {
  55603. prototype: WebGLQuery;
  55604. new(): WebGLQuery;
  55605. };
  55606. interface WebGLSampler extends WebGLObject {
  55607. }
  55608. declare var WebGLSampler: {
  55609. prototype: WebGLSampler;
  55610. new(): WebGLSampler;
  55611. };
  55612. interface WebGLSync extends WebGLObject {
  55613. }
  55614. declare var WebGLSync: {
  55615. prototype: WebGLSync;
  55616. new(): WebGLSync;
  55617. };
  55618. interface WebGLTransformFeedback extends WebGLObject {
  55619. }
  55620. declare var WebGLTransformFeedback: {
  55621. prototype: WebGLTransformFeedback;
  55622. new(): WebGLTransformFeedback;
  55623. };
  55624. interface WebGLVertexArrayObject extends WebGLObject {
  55625. }
  55626. declare var WebGLVertexArrayObject: {
  55627. prototype: WebGLVertexArrayObject;
  55628. new(): WebGLVertexArrayObject;
  55629. };
  55630. // Type definitions for WebVR API
  55631. // Project: https://w3c.github.io/webvr/
  55632. // Definitions by: six a <https://github.com/lostfictions>
  55633. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55634. interface VRDisplay extends EventTarget {
  55635. /**
  55636. * Dictionary of capabilities describing the VRDisplay.
  55637. */
  55638. readonly capabilities: VRDisplayCapabilities;
  55639. /**
  55640. * z-depth defining the far plane of the eye view frustum
  55641. * enables mapping of values in the render target depth
  55642. * attachment to scene coordinates. Initially set to 10000.0.
  55643. */
  55644. depthFar: number;
  55645. /**
  55646. * z-depth defining the near plane of the eye view frustum
  55647. * enables mapping of values in the render target depth
  55648. * attachment to scene coordinates. Initially set to 0.01.
  55649. */
  55650. depthNear: number;
  55651. /**
  55652. * An identifier for this distinct VRDisplay. Used as an
  55653. * association point in the Gamepad API.
  55654. */
  55655. readonly displayId: number;
  55656. /**
  55657. * A display name, a user-readable name identifying it.
  55658. */
  55659. readonly displayName: string;
  55660. readonly isConnected: boolean;
  55661. readonly isPresenting: boolean;
  55662. /**
  55663. * If this VRDisplay supports room-scale experiences, the optional
  55664. * stage attribute contains details on the room-scale parameters.
  55665. */
  55666. readonly stageParameters: VRStageParameters | null;
  55667. /**
  55668. * Passing the value returned by `requestAnimationFrame` to
  55669. * `cancelAnimationFrame` will unregister the callback.
  55670. * @param handle Define the hanle of the request to cancel
  55671. */
  55672. cancelAnimationFrame(handle: number): void;
  55673. /**
  55674. * Stops presenting to the VRDisplay.
  55675. * @returns a promise to know when it stopped
  55676. */
  55677. exitPresent(): Promise<void>;
  55678. /**
  55679. * Return the current VREyeParameters for the given eye.
  55680. * @param whichEye Define the eye we want the parameter for
  55681. * @returns the eye parameters
  55682. */
  55683. getEyeParameters(whichEye: string): VREyeParameters;
  55684. /**
  55685. * Populates the passed VRFrameData with the information required to render
  55686. * the current frame.
  55687. * @param frameData Define the data structure to populate
  55688. * @returns true if ok otherwise false
  55689. */
  55690. getFrameData(frameData: VRFrameData): boolean;
  55691. /**
  55692. * Get the layers currently being presented.
  55693. * @returns the list of VR layers
  55694. */
  55695. getLayers(): VRLayer[];
  55696. /**
  55697. * Return a VRPose containing the future predicted pose of the VRDisplay
  55698. * when the current frame will be presented. The value returned will not
  55699. * change until JavaScript has returned control to the browser.
  55700. *
  55701. * The VRPose will contain the position, orientation, velocity,
  55702. * and acceleration of each of these properties.
  55703. * @returns the pose object
  55704. */
  55705. getPose(): VRPose;
  55706. /**
  55707. * Return the current instantaneous pose of the VRDisplay, with no
  55708. * prediction applied.
  55709. * @returns the current instantaneous pose
  55710. */
  55711. getImmediatePose(): VRPose;
  55712. /**
  55713. * The callback passed to `requestAnimationFrame` will be called
  55714. * any time a new frame should be rendered. When the VRDisplay is
  55715. * presenting the callback will be called at the native refresh
  55716. * rate of the HMD. When not presenting this function acts
  55717. * identically to how window.requestAnimationFrame acts. Content should
  55718. * make no assumptions of frame rate or vsync behavior as the HMD runs
  55719. * asynchronously from other displays and at differing refresh rates.
  55720. * @param callback Define the eaction to run next frame
  55721. * @returns the request handle it
  55722. */
  55723. requestAnimationFrame(callback: FrameRequestCallback): number;
  55724. /**
  55725. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  55726. * Repeat calls while already presenting will update the VRLayers being displayed.
  55727. * @param layers Define the list of layer to present
  55728. * @returns a promise to know when the request has been fulfilled
  55729. */
  55730. requestPresent(layers: VRLayer[]): Promise<void>;
  55731. /**
  55732. * Reset the pose for this display, treating its current position and
  55733. * orientation as the "origin/zero" values. VRPose.position,
  55734. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  55735. * updated when calling resetPose(). This should be called in only
  55736. * sitting-space experiences.
  55737. */
  55738. resetPose(): void;
  55739. /**
  55740. * The VRLayer provided to the VRDisplay will be captured and presented
  55741. * in the HMD. Calling this function has the same effect on the source
  55742. * canvas as any other operation that uses its source image, and canvases
  55743. * created without preserveDrawingBuffer set to true will be cleared.
  55744. * @param pose Define the pose to submit
  55745. */
  55746. submitFrame(pose?: VRPose): void;
  55747. }
  55748. declare var VRDisplay: {
  55749. prototype: VRDisplay;
  55750. new(): VRDisplay;
  55751. };
  55752. interface VRLayer {
  55753. leftBounds?: number[] | Float32Array | null;
  55754. rightBounds?: number[] | Float32Array | null;
  55755. source?: HTMLCanvasElement | null;
  55756. }
  55757. interface VRDisplayCapabilities {
  55758. readonly canPresent: boolean;
  55759. readonly hasExternalDisplay: boolean;
  55760. readonly hasOrientation: boolean;
  55761. readonly hasPosition: boolean;
  55762. readonly maxLayers: number;
  55763. }
  55764. interface VREyeParameters {
  55765. /** @deprecated */
  55766. readonly fieldOfView: VRFieldOfView;
  55767. readonly offset: Float32Array;
  55768. readonly renderHeight: number;
  55769. readonly renderWidth: number;
  55770. }
  55771. interface VRFieldOfView {
  55772. readonly downDegrees: number;
  55773. readonly leftDegrees: number;
  55774. readonly rightDegrees: number;
  55775. readonly upDegrees: number;
  55776. }
  55777. interface VRFrameData {
  55778. readonly leftProjectionMatrix: Float32Array;
  55779. readonly leftViewMatrix: Float32Array;
  55780. readonly pose: VRPose;
  55781. readonly rightProjectionMatrix: Float32Array;
  55782. readonly rightViewMatrix: Float32Array;
  55783. readonly timestamp: number;
  55784. }
  55785. interface VRPose {
  55786. readonly angularAcceleration: Float32Array | null;
  55787. readonly angularVelocity: Float32Array | null;
  55788. readonly linearAcceleration: Float32Array | null;
  55789. readonly linearVelocity: Float32Array | null;
  55790. readonly orientation: Float32Array | null;
  55791. readonly position: Float32Array | null;
  55792. readonly timestamp: number;
  55793. }
  55794. interface VRStageParameters {
  55795. sittingToStandingTransform?: Float32Array;
  55796. sizeX?: number;
  55797. sizeY?: number;
  55798. }
  55799. interface Navigator {
  55800. getVRDisplays(): Promise<VRDisplay[]>;
  55801. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  55802. }
  55803. interface Window {
  55804. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  55805. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  55806. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  55807. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  55808. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  55809. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  55810. }
  55811. interface Gamepad {
  55812. readonly displayId: number;
  55813. }
  55814. interface XRDevice {
  55815. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  55816. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  55817. }
  55818. interface XRSession {
  55819. getInputSources(): Array<any>;
  55820. baseLayer: XRWebGLLayer;
  55821. requestFrameOfReference(type: string): Promise<void>;
  55822. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  55823. end(): Promise<void>;
  55824. requestAnimationFrame: Function;
  55825. addEventListener: Function;
  55826. }
  55827. interface XRSessionCreationOptions {
  55828. outputContext?: WebGLRenderingContext | null;
  55829. immersive?: boolean;
  55830. environmentIntegration?: boolean;
  55831. }
  55832. interface XRLayer {
  55833. getViewport: Function;
  55834. framebufferWidth: number;
  55835. framebufferHeight: number;
  55836. }
  55837. interface XRView {
  55838. projectionMatrix: Float32Array;
  55839. }
  55840. interface XRFrame {
  55841. getDevicePose: Function;
  55842. getInputPose: Function;
  55843. views: Array<XRView>;
  55844. baseLayer: XRLayer;
  55845. }
  55846. interface XRFrameOfReference {
  55847. }
  55848. interface XRWebGLLayer extends XRLayer {
  55849. framebuffer: WebGLFramebuffer;
  55850. }
  55851. declare var XRWebGLLayer: {
  55852. prototype: XRWebGLLayer;
  55853. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  55854. };
  55855. declare module BABYLON.GUI {
  55856. /**
  55857. * Class used to specific a value and its associated unit
  55858. */
  55859. export class ValueAndUnit {
  55860. /** defines the unit to store */
  55861. unit: number;
  55862. /** defines a boolean indicating if the value can be negative */
  55863. negativeValueAllowed: boolean;
  55864. private _value;
  55865. private _originalUnit;
  55866. /**
  55867. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  55868. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  55869. */
  55870. ignoreAdaptiveScaling: boolean;
  55871. /**
  55872. * Creates a new ValueAndUnit
  55873. * @param value defines the value to store
  55874. * @param unit defines the unit to store
  55875. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  55876. */
  55877. constructor(value: number,
  55878. /** defines the unit to store */
  55879. unit?: number,
  55880. /** defines a boolean indicating if the value can be negative */
  55881. negativeValueAllowed?: boolean);
  55882. /** Gets a boolean indicating if the value is a percentage */
  55883. readonly isPercentage: boolean;
  55884. /** Gets a boolean indicating if the value is store as pixel */
  55885. readonly isPixel: boolean;
  55886. /** Gets direct internal value */
  55887. readonly internalValue: number;
  55888. /**
  55889. * Gets value as pixel
  55890. * @param host defines the root host
  55891. * @param refValue defines the reference value for percentages
  55892. * @returns the value as pixel
  55893. */
  55894. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  55895. /**
  55896. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  55897. * @param value defines the value to store
  55898. * @param unit defines the unit to store
  55899. * @returns the current ValueAndUnit
  55900. */
  55901. updateInPlace(value: number, unit?: number): ValueAndUnit;
  55902. /**
  55903. * Gets the value accordingly to its unit
  55904. * @param host defines the root host
  55905. * @returns the value
  55906. */
  55907. getValue(host: AdvancedDynamicTexture): number;
  55908. /**
  55909. * Gets a string representation of the value
  55910. * @param host defines the root host
  55911. * @param decimals defines an optional number of decimals to display
  55912. * @returns a string
  55913. */
  55914. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  55915. /**
  55916. * Store a value parsed from a string
  55917. * @param source defines the source string
  55918. * @returns true if the value was successfully parsed
  55919. */
  55920. fromString(source: string | number): boolean;
  55921. private static _Regex;
  55922. private static _UNITMODE_PERCENTAGE;
  55923. private static _UNITMODE_PIXEL;
  55924. /** UNITMODE_PERCENTAGE */
  55925. static readonly UNITMODE_PERCENTAGE: number;
  55926. /** UNITMODE_PIXEL */
  55927. static readonly UNITMODE_PIXEL: number;
  55928. }
  55929. }
  55930. declare module BABYLON.GUI {
  55931. /**
  55932. * Define a style used by control to automatically setup properties based on a template.
  55933. * Only support font related properties so far
  55934. */
  55935. export class Style implements BABYLON.IDisposable {
  55936. private _fontFamily;
  55937. private _fontStyle;
  55938. private _fontWeight;
  55939. /** @hidden */ host: AdvancedDynamicTexture;
  55940. /** @hidden */ fontSize: ValueAndUnit;
  55941. /**
  55942. * BABYLON.Observable raised when the style values are changed
  55943. */
  55944. onChangedObservable: BABYLON.Observable<Style>;
  55945. /**
  55946. * Creates a new style object
  55947. * @param host defines the AdvancedDynamicTexture which hosts this style
  55948. */
  55949. constructor(host: AdvancedDynamicTexture);
  55950. /**
  55951. * Gets or sets the font size
  55952. */
  55953. fontSize: string | number;
  55954. /**
  55955. * Gets or sets the font family
  55956. */
  55957. fontFamily: string;
  55958. /**
  55959. * Gets or sets the font style
  55960. */
  55961. fontStyle: string;
  55962. /** Gets or sets font weight */
  55963. fontWeight: string;
  55964. /** Dispose all associated resources */
  55965. dispose(): void;
  55966. }
  55967. }
  55968. declare module BABYLON.GUI {
  55969. /**
  55970. * Class used to transport BABYLON.Vector2 information for pointer events
  55971. */
  55972. export class Vector2WithInfo extends BABYLON.Vector2 {
  55973. /** defines the current mouse button index */
  55974. buttonIndex: number;
  55975. /**
  55976. * Creates a new Vector2WithInfo
  55977. * @param source defines the vector2 data to transport
  55978. * @param buttonIndex defines the current mouse button index
  55979. */
  55980. constructor(source: BABYLON.Vector2,
  55981. /** defines the current mouse button index */
  55982. buttonIndex?: number);
  55983. }
  55984. /** Class used to provide 2D matrix features */
  55985. export class Matrix2D {
  55986. /** Gets the internal array of 6 floats used to store matrix data */
  55987. m: Float32Array;
  55988. /**
  55989. * Creates a new matrix
  55990. * @param m00 defines value for (0, 0)
  55991. * @param m01 defines value for (0, 1)
  55992. * @param m10 defines value for (1, 0)
  55993. * @param m11 defines value for (1, 1)
  55994. * @param m20 defines value for (2, 0)
  55995. * @param m21 defines value for (2, 1)
  55996. */
  55997. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  55998. /**
  55999. * Fills the matrix from direct values
  56000. * @param m00 defines value for (0, 0)
  56001. * @param m01 defines value for (0, 1)
  56002. * @param m10 defines value for (1, 0)
  56003. * @param m11 defines value for (1, 1)
  56004. * @param m20 defines value for (2, 0)
  56005. * @param m21 defines value for (2, 1)
  56006. * @returns the current modified matrix
  56007. */
  56008. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  56009. /**
  56010. * Gets matrix determinant
  56011. * @returns the determinant
  56012. */
  56013. determinant(): number;
  56014. /**
  56015. * Inverses the matrix and stores it in a target matrix
  56016. * @param result defines the target matrix
  56017. * @returns the current matrix
  56018. */
  56019. invertToRef(result: Matrix2D): Matrix2D;
  56020. /**
  56021. * Multiplies the current matrix with another one
  56022. * @param other defines the second operand
  56023. * @param result defines the target matrix
  56024. * @returns the current matrix
  56025. */
  56026. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  56027. /**
  56028. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  56029. * @param x defines the x coordinate to transform
  56030. * @param y defines the x coordinate to transform
  56031. * @param result defines the target vector2
  56032. * @returns the current matrix
  56033. */
  56034. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  56035. /**
  56036. * Creates an identity matrix
  56037. * @returns a new matrix
  56038. */
  56039. static Identity(): Matrix2D;
  56040. /**
  56041. * Creates a translation matrix and stores it in a target matrix
  56042. * @param x defines the x coordinate of the translation
  56043. * @param y defines the y coordinate of the translation
  56044. * @param result defines the target matrix
  56045. */
  56046. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  56047. /**
  56048. * Creates a scaling matrix and stores it in a target matrix
  56049. * @param x defines the x coordinate of the scaling
  56050. * @param y defines the y coordinate of the scaling
  56051. * @param result defines the target matrix
  56052. */
  56053. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  56054. /**
  56055. * Creates a rotation matrix and stores it in a target matrix
  56056. * @param angle defines the rotation angle
  56057. * @param result defines the target matrix
  56058. */
  56059. static RotationToRef(angle: number, result: Matrix2D): void;
  56060. private static _TempPreTranslationMatrix;
  56061. private static _TempPostTranslationMatrix;
  56062. private static _TempRotationMatrix;
  56063. private static _TempScalingMatrix;
  56064. private static _TempCompose0;
  56065. private static _TempCompose1;
  56066. private static _TempCompose2;
  56067. /**
  56068. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  56069. * @param tx defines the x coordinate of the translation
  56070. * @param ty defines the y coordinate of the translation
  56071. * @param angle defines the rotation angle
  56072. * @param scaleX defines the x coordinate of the scaling
  56073. * @param scaleY defines the y coordinate of the scaling
  56074. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  56075. * @param result defines the target matrix
  56076. */
  56077. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  56078. }
  56079. }
  56080. declare module BABYLON.GUI {
  56081. /**
  56082. * Class used to store 2D control sizes
  56083. */
  56084. export class Measure {
  56085. /** defines left coordinate */
  56086. left: number;
  56087. /** defines top coordinate */
  56088. top: number;
  56089. /** defines width dimension */
  56090. width: number;
  56091. /** defines height dimension */
  56092. height: number;
  56093. /**
  56094. * Creates a new measure
  56095. * @param left defines left coordinate
  56096. * @param top defines top coordinate
  56097. * @param width defines width dimension
  56098. * @param height defines height dimension
  56099. */
  56100. constructor(
  56101. /** defines left coordinate */
  56102. left: number,
  56103. /** defines top coordinate */
  56104. top: number,
  56105. /** defines width dimension */
  56106. width: number,
  56107. /** defines height dimension */
  56108. height: number);
  56109. /**
  56110. * Copy from another measure
  56111. * @param other defines the other measure to copy from
  56112. */
  56113. copyFrom(other: Measure): void;
  56114. /**
  56115. * Copy from a group of 4 floats
  56116. * @param left defines left coordinate
  56117. * @param top defines top coordinate
  56118. * @param width defines width dimension
  56119. * @param height defines height dimension
  56120. */
  56121. copyFromFloats(left: number, top: number, width: number, height: number): void;
  56122. /**
  56123. * Computes the axis aligned bounding box measure for two given measures
  56124. * @param a Input measure
  56125. * @param b Input measure
  56126. * @param result the resulting bounding measure
  56127. */
  56128. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  56129. /**
  56130. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  56131. * @param transform the matrix to transform the measure before computing the AABB
  56132. * @param result the resulting AABB
  56133. */
  56134. transformToRef(transform: Matrix2D, result: Measure): void;
  56135. /**
  56136. * Check equality between this measure and another one
  56137. * @param other defines the other measures
  56138. * @returns true if both measures are equals
  56139. */
  56140. isEqualsTo(other: Measure): boolean;
  56141. /**
  56142. * Creates an empty measure
  56143. * @returns a new measure
  56144. */
  56145. static Empty(): Measure;
  56146. }
  56147. }
  56148. declare module BABYLON.GUI {
  56149. /**
  56150. * Interface used to define a control that can receive focus
  56151. */
  56152. export interface IFocusableControl {
  56153. /**
  56154. * Function called when the control receives the focus
  56155. */
  56156. onFocus(): void;
  56157. /**
  56158. * Function called when the control loses the focus
  56159. */
  56160. onBlur(): void;
  56161. /**
  56162. * Function called to let the control handle keyboard events
  56163. * @param evt defines the current keyboard event
  56164. */
  56165. processKeyboard(evt: KeyboardEvent): void;
  56166. /**
  56167. * Function called to get the list of controls that should not steal the focus from this control
  56168. * @returns an array of controls
  56169. */
  56170. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  56171. }
  56172. /**
  56173. * Class used to create texture to support 2D GUI elements
  56174. * @see http://doc.babylonjs.com/how_to/gui
  56175. */
  56176. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  56177. private _isDirty;
  56178. private _renderObserver;
  56179. private _resizeObserver;
  56180. private _preKeyboardObserver;
  56181. private _pointerMoveObserver;
  56182. private _pointerObserver;
  56183. private _canvasPointerOutObserver;
  56184. private _background;
  56185. /** @hidden */ rootContainer: Container;
  56186. /** @hidden */ lastPickedControl: Control;
  56187. /** @hidden */ lastControlOver: {
  56188. [pointerId: number]: Control;
  56189. };
  56190. /** @hidden */ lastControlDown: {
  56191. [pointerId: number]: Control;
  56192. };
  56193. /** @hidden */ capturingControl: {
  56194. [pointerId: number]: Control;
  56195. };
  56196. /** @hidden */ shouldBlockPointer: boolean;
  56197. /** @hidden */ layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  56198. /** @hidden */ linkedControls: Control[];
  56199. private _isFullscreen;
  56200. private _fullscreenViewport;
  56201. private _idealWidth;
  56202. private _idealHeight;
  56203. private _useSmallestIdeal;
  56204. private _renderAtIdealSize;
  56205. private _focusedControl;
  56206. private _blockNextFocusCheck;
  56207. private _renderScale;
  56208. private _rootCanvas;
  56209. private _cursorChanged;
  56210. /**
  56211. * Define type to string to ensure compatibility across browsers
  56212. * Safari doesn't support DataTransfer constructor
  56213. */
  56214. private _clipboardData;
  56215. /**
  56216. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  56217. */
  56218. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  56219. /**
  56220. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  56221. */
  56222. onControlPickedObservable: BABYLON.Observable<Control>;
  56223. /**
  56224. * BABYLON.Observable event triggered before layout is evaluated
  56225. */
  56226. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56227. /**
  56228. * BABYLON.Observable event triggered after the layout was evaluated
  56229. */
  56230. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56231. /**
  56232. * BABYLON.Observable event triggered before the texture is rendered
  56233. */
  56234. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56235. /**
  56236. * BABYLON.Observable event triggered after the texture was rendered
  56237. */
  56238. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56239. /**
  56240. * Gets or sets a boolean defining if alpha is stored as premultiplied
  56241. */
  56242. premulAlpha: boolean;
  56243. /**
  56244. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  56245. * Useful when you want more antialiasing
  56246. */
  56247. renderScale: number;
  56248. /** Gets or sets the background color */
  56249. background: string;
  56250. /**
  56251. * Gets or sets the ideal width used to design controls.
  56252. * The GUI will then rescale everything accordingly
  56253. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56254. */
  56255. idealWidth: number;
  56256. /**
  56257. * Gets or sets the ideal height used to design controls.
  56258. * The GUI will then rescale everything accordingly
  56259. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56260. */
  56261. idealHeight: number;
  56262. /**
  56263. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  56264. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56265. */
  56266. useSmallestIdeal: boolean;
  56267. /**
  56268. * Gets or sets a boolean indicating if adaptive scaling must be used
  56269. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56270. */
  56271. renderAtIdealSize: boolean;
  56272. /**
  56273. * Gets the underlying layer used to render the texture when in fullscreen mode
  56274. */
  56275. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  56276. /**
  56277. * Gets the root container control
  56278. */
  56279. readonly rootContainer: Container;
  56280. /**
  56281. * Returns an array containing the root container.
  56282. * This is mostly used to let the Inspector introspects the ADT
  56283. * @returns an array containing the rootContainer
  56284. */
  56285. getChildren(): Array<Container>;
  56286. /**
  56287. * Will return all controls that are inside this texture
  56288. * @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
  56289. * @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
  56290. * @return all child controls
  56291. */
  56292. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  56293. /**
  56294. * Gets or sets the current focused control
  56295. */
  56296. focusedControl: BABYLON.Nullable<IFocusableControl>;
  56297. /**
  56298. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  56299. */
  56300. isForeground: boolean;
  56301. /**
  56302. * Gets or set information about clipboardData
  56303. */
  56304. clipboardData: string;
  56305. /**
  56306. * Creates a new AdvancedDynamicTexture
  56307. * @param name defines the name of the texture
  56308. * @param width defines the width of the texture
  56309. * @param height defines the height of the texture
  56310. * @param scene defines the hosting scene
  56311. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  56312. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  56313. */
  56314. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  56315. /**
  56316. * Get the current class name of the texture useful for serialization or dynamic coding.
  56317. * @returns "AdvancedDynamicTexture"
  56318. */
  56319. getClassName(): string;
  56320. /**
  56321. * Function used to execute a function on all controls
  56322. * @param func defines the function to execute
  56323. * @param container defines the container where controls belong. If null the root container will be used
  56324. */
  56325. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  56326. private _useInvalidateRectOptimization;
  56327. /**
  56328. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  56329. */
  56330. useInvalidateRectOptimization: boolean;
  56331. private _invalidatedRectangle;
  56332. /**
  56333. * Invalidates a rectangle area on the gui texture
  56334. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  56335. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  56336. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  56337. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  56338. */
  56339. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  56340. /**
  56341. * Marks the texture as dirty forcing a complete update
  56342. */
  56343. markAsDirty(): void;
  56344. /**
  56345. * Helper function used to create a new style
  56346. * @returns a new style
  56347. * @see http://doc.babylonjs.com/how_to/gui#styles
  56348. */
  56349. createStyle(): Style;
  56350. /**
  56351. * Adds a new control to the root container
  56352. * @param control defines the control to add
  56353. * @returns the current texture
  56354. */
  56355. addControl(control: Control): AdvancedDynamicTexture;
  56356. /**
  56357. * Removes a control from the root container
  56358. * @param control defines the control to remove
  56359. * @returns the current texture
  56360. */
  56361. removeControl(control: Control): AdvancedDynamicTexture;
  56362. /**
  56363. * Release all resources
  56364. */
  56365. dispose(): void;
  56366. private _onResize;
  56367. /** @hidden */ getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  56368. /**
  56369. * Get screen coordinates for a vector3
  56370. * @param position defines the position to project
  56371. * @param worldMatrix defines the world matrix to use
  56372. * @returns the projected position
  56373. */
  56374. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  56375. private _checkUpdate;
  56376. private _clearMeasure;
  56377. private _render;
  56378. /** @hidden */ changeCursor(cursor: string): void;
  56379. /** @hidden */ registerLastControlDown(control: Control, pointerId: number): void;
  56380. private _doPicking;
  56381. /** @hidden */ cleanControlAfterRemovalFromList(list: {
  56382. [pointerId: number]: Control;
  56383. }, control: Control): void;
  56384. /** @hidden */ cleanControlAfterRemoval(control: Control): void;
  56385. /** Attach to all scene events required to support pointer events */
  56386. attach(): void;
  56387. /** @hidden */
  56388. private onClipboardCopy;
  56389. /** @hidden */
  56390. private onClipboardCut;
  56391. /** @hidden */
  56392. private onClipboardPaste;
  56393. /**
  56394. * Register the clipboard Events onto the canvas
  56395. */
  56396. registerClipboardEvents(): void;
  56397. /**
  56398. * Unregister the clipboard Events from the canvas
  56399. */
  56400. unRegisterClipboardEvents(): void;
  56401. /**
  56402. * Connect the texture to a hosting mesh to enable interactions
  56403. * @param mesh defines the mesh to attach to
  56404. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  56405. */
  56406. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  56407. /**
  56408. * Move the focus to a specific control
  56409. * @param control defines the control which will receive the focus
  56410. */
  56411. moveFocusToControl(control: IFocusableControl): void;
  56412. private _manageFocus;
  56413. private _attachToOnPointerOut;
  56414. /**
  56415. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  56416. * @param mesh defines the mesh which will receive the texture
  56417. * @param width defines the texture width (1024 by default)
  56418. * @param height defines the texture height (1024 by default)
  56419. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  56420. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  56421. * @returns a new AdvancedDynamicTexture
  56422. */
  56423. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  56424. /**
  56425. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  56426. * In this mode the texture will rely on a layer for its rendering.
  56427. * This allows it to be treated like any other layer.
  56428. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  56429. * LayerMask is set through advancedTexture.layer.layerMask
  56430. * @param name defines name for the texture
  56431. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  56432. * @param scene defines the hsoting scene
  56433. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  56434. * @returns a new AdvancedDynamicTexture
  56435. */
  56436. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  56437. }
  56438. }
  56439. declare module BABYLON.GUI {
  56440. /**
  56441. * Root class used for all 2D controls
  56442. * @see http://doc.babylonjs.com/how_to/gui#controls
  56443. */
  56444. export class Control {
  56445. /** defines the name of the control */
  56446. name?: string | undefined;
  56447. /**
  56448. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  56449. */
  56450. static AllowAlphaInheritance: boolean;
  56451. private _alpha;
  56452. private _alphaSet;
  56453. private _zIndex;
  56454. /** @hidden */ host: AdvancedDynamicTexture;
  56455. /** Gets or sets the control parent */
  56456. parent: BABYLON.Nullable<Container>;
  56457. /** @hidden */ currentMeasure: Measure;
  56458. private _fontFamily;
  56459. private _fontStyle;
  56460. private _fontWeight;
  56461. private _fontSize;
  56462. private _font;
  56463. /** @hidden */ width: ValueAndUnit;
  56464. /** @hidden */ height: ValueAndUnit;
  56465. /** @hidden */
  56466. protected _fontOffset: {
  56467. ascent: number;
  56468. height: number;
  56469. descent: number;
  56470. };
  56471. private _color;
  56472. private _style;
  56473. private _styleObserver;
  56474. /** @hidden */
  56475. protected _horizontalAlignment: number;
  56476. /** @hidden */
  56477. protected _verticalAlignment: number;
  56478. /** @hidden */
  56479. protected _isDirty: boolean;
  56480. /** @hidden */
  56481. protected _wasDirty: boolean;
  56482. /** @hidden */ tempParentMeasure: Measure;
  56483. /** @hidden */ prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  56484. /** @hidden */
  56485. protected _cachedParentMeasure: Measure;
  56486. private _paddingLeft;
  56487. private _paddingRight;
  56488. private _paddingTop;
  56489. private _paddingBottom;
  56490. /** @hidden */ left: ValueAndUnit;
  56491. /** @hidden */ top: ValueAndUnit;
  56492. private _scaleX;
  56493. private _scaleY;
  56494. private _rotation;
  56495. private _transformCenterX;
  56496. private _transformCenterY;
  56497. /** @hidden */ transformMatrix: Matrix2D;
  56498. /** @hidden */
  56499. protected _invertTransformMatrix: Matrix2D;
  56500. /** @hidden */
  56501. protected _transformedPosition: BABYLON.Vector2;
  56502. private _isMatrixDirty;
  56503. private _cachedOffsetX;
  56504. private _cachedOffsetY;
  56505. private _isVisible;
  56506. private _isHighlighted;
  56507. /** @hidden */ linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  56508. private _fontSet;
  56509. private _dummyVector2;
  56510. private _downCount;
  56511. private _enterCount;
  56512. private _doNotRender;
  56513. private _downPointerIds;
  56514. protected _isEnabled: boolean;
  56515. protected _disabledColor: string;
  56516. /** @hidden */
  56517. protected _rebuildLayout: boolean;
  56518. /** @hidden */ isClipped: boolean;
  56519. /** @hidden */ tag: any;
  56520. /**
  56521. * Gets or sets the unique id of the node. Please note that this number will be updated when the control is added to a container
  56522. */
  56523. uniqueId: number;
  56524. /**
  56525. * Gets or sets an object used to store user defined information for the node
  56526. */
  56527. metadata: any;
  56528. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  56529. isHitTestVisible: boolean;
  56530. /** Gets or sets a boolean indicating if the control can block pointer events */
  56531. isPointerBlocker: boolean;
  56532. /** Gets or sets a boolean indicating if the control can be focusable */
  56533. isFocusInvisible: boolean;
  56534. /**
  56535. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  56536. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  56537. */
  56538. clipChildren: boolean;
  56539. /**
  56540. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  56541. */
  56542. useBitmapCache: boolean;
  56543. private _cacheData;
  56544. private _shadowOffsetX;
  56545. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  56546. shadowOffsetX: number;
  56547. private _shadowOffsetY;
  56548. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  56549. shadowOffsetY: number;
  56550. private _shadowBlur;
  56551. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  56552. shadowBlur: number;
  56553. private _shadowColor;
  56554. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  56555. shadowColor: string;
  56556. /** Gets or sets the cursor to use when the control is hovered */
  56557. hoverCursor: string;
  56558. /** @hidden */
  56559. protected _linkOffsetX: ValueAndUnit;
  56560. /** @hidden */
  56561. protected _linkOffsetY: ValueAndUnit;
  56562. /** Gets the control type name */
  56563. readonly typeName: string;
  56564. /**
  56565. * Get the current class name of the control.
  56566. * @returns current class name
  56567. */
  56568. getClassName(): string;
  56569. /**
  56570. * An event triggered when the pointer move over the control.
  56571. */
  56572. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  56573. /**
  56574. * An event triggered when the pointer move out of the control.
  56575. */
  56576. onPointerOutObservable: BABYLON.Observable<Control>;
  56577. /**
  56578. * An event triggered when the pointer taps the control
  56579. */
  56580. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  56581. /**
  56582. * An event triggered when pointer up
  56583. */
  56584. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  56585. /**
  56586. * An event triggered when a control is clicked on
  56587. */
  56588. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  56589. /**
  56590. * An event triggered when pointer enters the control
  56591. */
  56592. onPointerEnterObservable: BABYLON.Observable<Control>;
  56593. /**
  56594. * An event triggered when the control is marked as dirty
  56595. */
  56596. onDirtyObservable: BABYLON.Observable<Control>;
  56597. /**
  56598. * An event triggered before drawing the control
  56599. */
  56600. onBeforeDrawObservable: BABYLON.Observable<Control>;
  56601. /**
  56602. * An event triggered after the control was drawn
  56603. */
  56604. onAfterDrawObservable: BABYLON.Observable<Control>;
  56605. /**
  56606. * Get the hosting AdvancedDynamicTexture
  56607. */
  56608. readonly host: AdvancedDynamicTexture;
  56609. /** Gets or set information about font offsets (used to render and align text) */
  56610. fontOffset: {
  56611. ascent: number;
  56612. height: number;
  56613. descent: number;
  56614. };
  56615. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  56616. alpha: number;
  56617. /**
  56618. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  56619. */
  56620. isHighlighted: boolean;
  56621. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  56622. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56623. */
  56624. scaleX: number;
  56625. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  56626. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56627. */
  56628. scaleY: number;
  56629. /** Gets or sets the rotation angle (0 by default)
  56630. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56631. */
  56632. rotation: number;
  56633. /** Gets or sets the transformation center on Y axis (0 by default)
  56634. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56635. */
  56636. transformCenterY: number;
  56637. /** Gets or sets the transformation center on X axis (0 by default)
  56638. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56639. */
  56640. transformCenterX: number;
  56641. /**
  56642. * Gets or sets the horizontal alignment
  56643. * @see http://doc.babylonjs.com/how_to/gui#alignments
  56644. */
  56645. horizontalAlignment: number;
  56646. /**
  56647. * Gets or sets the vertical alignment
  56648. * @see http://doc.babylonjs.com/how_to/gui#alignments
  56649. */
  56650. verticalAlignment: number;
  56651. /**
  56652. * Gets or sets control width
  56653. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56654. */
  56655. width: string | number;
  56656. /**
  56657. * Gets control width in pixel
  56658. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56659. */
  56660. readonly widthInPixels: number;
  56661. /**
  56662. * Gets or sets control height
  56663. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56664. */
  56665. height: string | number;
  56666. /**
  56667. * Gets control height in pixel
  56668. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56669. */
  56670. readonly heightInPixels: number;
  56671. /** Gets or set font family */
  56672. fontFamily: string;
  56673. /** Gets or sets font style */
  56674. fontStyle: string;
  56675. /** Gets or sets font weight */
  56676. fontWeight: string;
  56677. /**
  56678. * Gets or sets style
  56679. * @see http://doc.babylonjs.com/how_to/gui#styles
  56680. */
  56681. style: BABYLON.Nullable<Style>;
  56682. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  56683. /** Gets font size in pixels */
  56684. readonly fontSizeInPixels: number;
  56685. /** Gets or sets font size */
  56686. fontSize: string | number;
  56687. /** Gets or sets foreground color */
  56688. color: string;
  56689. /** Gets or sets z index which is used to reorder controls on the z axis */
  56690. zIndex: number;
  56691. /** Gets or sets a boolean indicating if the control can be rendered */
  56692. notRenderable: boolean;
  56693. /** Gets or sets a boolean indicating if the control is visible */
  56694. isVisible: boolean;
  56695. /** Gets a boolean indicating that the control needs to update its rendering */
  56696. readonly isDirty: boolean;
  56697. /**
  56698. * Gets the current linked mesh (or null if none)
  56699. */
  56700. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  56701. /**
  56702. * Gets or sets a value indicating the padding to use on the left of the control
  56703. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56704. */
  56705. paddingLeft: string | number;
  56706. /**
  56707. * Gets a value indicating the padding in pixels to use on the left of the control
  56708. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56709. */
  56710. readonly paddingLeftInPixels: number;
  56711. /**
  56712. * Gets or sets a value indicating the padding to use on the right of the control
  56713. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56714. */
  56715. paddingRight: string | number;
  56716. /**
  56717. * Gets a value indicating the padding in pixels to use on the right of the control
  56718. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56719. */
  56720. readonly paddingRightInPixels: number;
  56721. /**
  56722. * Gets or sets a value indicating the padding to use on the top of the control
  56723. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56724. */
  56725. paddingTop: string | number;
  56726. /**
  56727. * Gets a value indicating the padding in pixels to use on the top of the control
  56728. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56729. */
  56730. readonly paddingTopInPixels: number;
  56731. /**
  56732. * Gets or sets a value indicating the padding to use on the bottom of the control
  56733. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56734. */
  56735. paddingBottom: string | number;
  56736. /**
  56737. * Gets a value indicating the padding in pixels to use on the bottom of the control
  56738. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56739. */
  56740. readonly paddingBottomInPixels: number;
  56741. /**
  56742. * Gets or sets a value indicating the left coordinate of the control
  56743. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56744. */
  56745. left: string | number;
  56746. /**
  56747. * Gets a value indicating the left coordinate in pixels of the control
  56748. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56749. */
  56750. readonly leftInPixels: number;
  56751. /**
  56752. * Gets or sets a value indicating the top coordinate of the control
  56753. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56754. */
  56755. top: string | number;
  56756. /**
  56757. * Gets a value indicating the top coordinate in pixels of the control
  56758. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56759. */
  56760. readonly topInPixels: number;
  56761. /**
  56762. * Gets or sets a value indicating the offset on X axis to the linked mesh
  56763. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56764. */
  56765. linkOffsetX: string | number;
  56766. /**
  56767. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  56768. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56769. */
  56770. readonly linkOffsetXInPixels: number;
  56771. /**
  56772. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  56773. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56774. */
  56775. linkOffsetY: string | number;
  56776. /**
  56777. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  56778. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56779. */
  56780. readonly linkOffsetYInPixels: number;
  56781. /** Gets the center coordinate on X axis */
  56782. readonly centerX: number;
  56783. /** Gets the center coordinate on Y axis */
  56784. readonly centerY: number;
  56785. /** Gets or sets if control is Enabled*/
  56786. isEnabled: boolean;
  56787. /** Gets or sets background color of control if it's disabled*/
  56788. disabledColor: string;
  56789. /**
  56790. * Creates a new control
  56791. * @param name defines the name of the control
  56792. */
  56793. constructor(
  56794. /** defines the name of the control */
  56795. name?: string | undefined);
  56796. /** @hidden */
  56797. protected _getTypeName(): string;
  56798. /**
  56799. * Gets the first ascendant in the hierarchy of the given type
  56800. * @param className defines the required type
  56801. * @returns the ascendant or null if not found
  56802. */
  56803. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  56804. /** @hidden */ resetFontCache(): void;
  56805. /**
  56806. * Determines if a container is an ascendant of the current control
  56807. * @param container defines the container to look for
  56808. * @returns true if the container is one of the ascendant of the control
  56809. */
  56810. isAscendant(container: Control): boolean;
  56811. /**
  56812. * Gets coordinates in local control space
  56813. * @param globalCoordinates defines the coordinates to transform
  56814. * @returns the new coordinates in local space
  56815. */
  56816. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  56817. /**
  56818. * Gets coordinates in local control space
  56819. * @param globalCoordinates defines the coordinates to transform
  56820. * @param result defines the target vector2 where to store the result
  56821. * @returns the current control
  56822. */
  56823. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  56824. /**
  56825. * Gets coordinates in parent local control space
  56826. * @param globalCoordinates defines the coordinates to transform
  56827. * @returns the new coordinates in parent local space
  56828. */
  56829. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  56830. /**
  56831. * Move the current control to a vector3 position projected onto the screen.
  56832. * @param position defines the target position
  56833. * @param scene defines the hosting scene
  56834. */
  56835. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  56836. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  56837. /**
  56838. * Will return all controls that have this control as ascendant
  56839. * @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
  56840. * @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
  56841. * @return all child controls
  56842. */
  56843. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  56844. /**
  56845. * Link current control with a target mesh
  56846. * @param mesh defines the mesh to link with
  56847. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56848. */
  56849. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  56850. /** @hidden */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  56851. /** @hidden */ offsetLeft(offset: number): void;
  56852. /** @hidden */ offsetTop(offset: number): void;
  56853. /** @hidden */ markMatrixAsDirty(): void;
  56854. /** @hidden */ flagDescendantsAsMatrixDirty(): void;
  56855. /** @hidden */ intersectsRect(rect: Measure): boolean;
  56856. /** @hidden */
  56857. protected invalidateRect(): void;
  56858. /** @hidden */ markAsDirty(force?: boolean): void;
  56859. /** @hidden */ markAllAsDirty(): void;
  56860. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  56861. /** @hidden */
  56862. protected _transform(context?: CanvasRenderingContext2D): void;
  56863. /** @hidden */ renderHighlight(context: CanvasRenderingContext2D): void;
  56864. /** @hidden */ renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  56865. /** @hidden */
  56866. protected _applyStates(context: CanvasRenderingContext2D): void;
  56867. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  56868. /** @hidden */
  56869. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  56870. protected _evaluateClippingState(parentMeasure: Measure): void;
  56871. /** @hidden */ measure(): void;
  56872. /** @hidden */
  56873. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  56874. /** @hidden */
  56875. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  56876. /** @hidden */
  56877. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  56878. /** @hidden */
  56879. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  56880. private static _ClipMeasure;
  56881. private _tmpMeasureA;
  56882. private _clip;
  56883. /** @hidden */ render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  56884. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  56885. /**
  56886. * Tests if a given coordinates belong to the current control
  56887. * @param x defines x coordinate to test
  56888. * @param y defines y coordinate to test
  56889. * @returns true if the coordinates are inside the control
  56890. */
  56891. contains(x: number, y: number): boolean;
  56892. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  56893. /** @hidden */ onPointerMove(target: Control, coordinates: BABYLON.Vector2): void;
  56894. /** @hidden */ onPointerEnter(target: Control): boolean;
  56895. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  56896. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  56897. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  56898. /** @hidden */ forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  56899. /** @hidden */ processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  56900. private _prepareFont;
  56901. /** Releases associated resources */
  56902. dispose(): void;
  56903. private static _HORIZONTAL_ALIGNMENT_LEFT;
  56904. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  56905. private static _HORIZONTAL_ALIGNMENT_CENTER;
  56906. private static _VERTICAL_ALIGNMENT_TOP;
  56907. private static _VERTICAL_ALIGNMENT_BOTTOM;
  56908. private static _VERTICAL_ALIGNMENT_CENTER;
  56909. /** HORIZONTAL_ALIGNMENT_LEFT */
  56910. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  56911. /** HORIZONTAL_ALIGNMENT_RIGHT */
  56912. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  56913. /** HORIZONTAL_ALIGNMENT_CENTER */
  56914. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  56915. /** VERTICAL_ALIGNMENT_TOP */
  56916. static readonly VERTICAL_ALIGNMENT_TOP: number;
  56917. /** VERTICAL_ALIGNMENT_BOTTOM */
  56918. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  56919. /** VERTICAL_ALIGNMENT_CENTER */
  56920. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  56921. private static _FontHeightSizes;
  56922. /** @hidden */ private static _GetFontOffset(font: string): {
  56923. ascent: number;
  56924. height: number;
  56925. descent: number;
  56926. };
  56927. /**
  56928. * Creates a stack panel that can be used to render headers
  56929. * @param control defines the control to associate with the header
  56930. * @param text defines the text of the header
  56931. * @param size defines the size of the header
  56932. * @param options defines options used to configure the header
  56933. * @returns a new StackPanel
  56934. * @ignore
  56935. * @hidden
  56936. */
  56937. static AddHeader: (control: Control, text: string, size: string | number, options: {
  56938. isHorizontal: boolean;
  56939. controlFirst: boolean;
  56940. }) => any;
  56941. /** @hidden */
  56942. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  56943. }
  56944. }
  56945. declare module BABYLON.GUI {
  56946. /**
  56947. * Root class for 2D containers
  56948. * @see http://doc.babylonjs.com/how_to/gui#containers
  56949. */
  56950. export class Container extends Control {
  56951. name?: string | undefined;
  56952. /** @hidden */
  56953. protected _children: Control[];
  56954. /** @hidden */
  56955. protected _measureForChildren: Measure;
  56956. /** @hidden */
  56957. protected _background: string;
  56958. /** @hidden */
  56959. protected _adaptWidthToChildren: boolean;
  56960. /** @hidden */
  56961. protected _adaptHeightToChildren: boolean;
  56962. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  56963. adaptHeightToChildren: boolean;
  56964. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  56965. adaptWidthToChildren: boolean;
  56966. /** Gets or sets background color */
  56967. background: string;
  56968. /** Gets the list of children */
  56969. readonly children: Control[];
  56970. /**
  56971. * Creates a new Container
  56972. * @param name defines the name of the container
  56973. */
  56974. constructor(name?: string | undefined);
  56975. protected _getTypeName(): string; flagDescendantsAsMatrixDirty(): void;
  56976. /**
  56977. * Gets a child using its name
  56978. * @param name defines the child name to look for
  56979. * @returns the child control if found
  56980. */
  56981. getChildByName(name: string): BABYLON.Nullable<Control>;
  56982. /**
  56983. * Gets a child using its type and its name
  56984. * @param name defines the child name to look for
  56985. * @param type defines the child type to look for
  56986. * @returns the child control if found
  56987. */
  56988. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  56989. /**
  56990. * Search for a specific control in children
  56991. * @param control defines the control to look for
  56992. * @returns true if the control is in child list
  56993. */
  56994. containsControl(control: Control): boolean;
  56995. /**
  56996. * Adds a new control to the current container
  56997. * @param control defines the control to add
  56998. * @returns the current container
  56999. */
  57000. addControl(control: BABYLON.Nullable<Control>): Container;
  57001. /**
  57002. * Removes all controls from the current container
  57003. * @returns the current container
  57004. */
  57005. clearControls(): Container;
  57006. /**
  57007. * Removes a control from the current container
  57008. * @param control defines the control to remove
  57009. * @returns the current container
  57010. */
  57011. removeControl(control: Control): Container;
  57012. /** @hidden */ reOrderControl(control: Control): void;
  57013. /** @hidden */ offsetLeft(offset: number): void;
  57014. /** @hidden */ offsetTop(offset: number): void;
  57015. /** @hidden */ markAllAsDirty(): void;
  57016. /** @hidden */
  57017. protected _localDraw(context: CanvasRenderingContext2D): void;
  57018. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  57019. /** @hidden */
  57020. protected _beforeLayout(): void;
  57021. /** @hidden */
  57022. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57023. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  57024. protected _postMeasure(): void;
  57025. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  57026. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  57027. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57028. /** @hidden */
  57029. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57030. /** Releases associated resources */
  57031. dispose(): void;
  57032. }
  57033. }
  57034. declare module BABYLON.GUI {
  57035. /** Class used to create rectangle container */
  57036. export class Rectangle extends Container {
  57037. name?: string | undefined;
  57038. private _thickness;
  57039. private _cornerRadius;
  57040. /** Gets or sets border thickness */
  57041. thickness: number;
  57042. /** Gets or sets the corner radius angle */
  57043. cornerRadius: number;
  57044. /**
  57045. * Creates a new Rectangle
  57046. * @param name defines the control name
  57047. */
  57048. constructor(name?: string | undefined);
  57049. protected _getTypeName(): string;
  57050. protected _localDraw(context: CanvasRenderingContext2D): void;
  57051. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57052. private _drawRoundedRect;
  57053. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  57054. }
  57055. }
  57056. declare module BABYLON.GUI {
  57057. /**
  57058. * Enum that determines the text-wrapping mode to use.
  57059. */
  57060. export enum TextWrapping {
  57061. /**
  57062. * Clip the text when it's larger than Control.width; this is the default mode.
  57063. */
  57064. Clip = 0,
  57065. /**
  57066. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  57067. */
  57068. WordWrap = 1,
  57069. /**
  57070. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  57071. */
  57072. Ellipsis = 2
  57073. }
  57074. /**
  57075. * Class used to create text block control
  57076. */
  57077. export class TextBlock extends Control {
  57078. /**
  57079. * Defines the name of the control
  57080. */
  57081. name?: string | undefined;
  57082. private _text;
  57083. private _textWrapping;
  57084. private _textHorizontalAlignment;
  57085. private _textVerticalAlignment;
  57086. private _lines;
  57087. private _resizeToFit;
  57088. private _lineSpacing;
  57089. private _outlineWidth;
  57090. private _outlineColor;
  57091. /**
  57092. * An event triggered after the text is changed
  57093. */
  57094. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  57095. /**
  57096. * An event triggered after the text was broken up into lines
  57097. */
  57098. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  57099. /**
  57100. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  57101. */
  57102. readonly lines: any[];
  57103. /**
  57104. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  57105. */
  57106. /**
  57107. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  57108. */
  57109. resizeToFit: boolean;
  57110. /**
  57111. * Gets or sets a boolean indicating if text must be wrapped
  57112. */
  57113. /**
  57114. * Gets or sets a boolean indicating if text must be wrapped
  57115. */
  57116. textWrapping: TextWrapping | boolean;
  57117. /**
  57118. * Gets or sets text to display
  57119. */
  57120. /**
  57121. * Gets or sets text to display
  57122. */
  57123. text: string;
  57124. /**
  57125. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  57126. */
  57127. /**
  57128. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  57129. */
  57130. textHorizontalAlignment: number;
  57131. /**
  57132. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  57133. */
  57134. /**
  57135. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  57136. */
  57137. textVerticalAlignment: number;
  57138. /**
  57139. * Gets or sets line spacing value
  57140. */
  57141. /**
  57142. * Gets or sets line spacing value
  57143. */
  57144. lineSpacing: string | number;
  57145. /**
  57146. * Gets or sets outlineWidth of the text to display
  57147. */
  57148. /**
  57149. * Gets or sets outlineWidth of the text to display
  57150. */
  57151. outlineWidth: number;
  57152. /**
  57153. * Gets or sets outlineColor of the text to display
  57154. */
  57155. /**
  57156. * Gets or sets outlineColor of the text to display
  57157. */
  57158. outlineColor: string;
  57159. /**
  57160. * Creates a new TextBlock object
  57161. * @param name defines the name of the control
  57162. * @param text defines the text to display (emptry string by default)
  57163. */
  57164. constructor(
  57165. /**
  57166. * Defines the name of the control
  57167. */
  57168. name?: string | undefined, text?: string);
  57169. protected _getTypeName(): string;
  57170. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57171. private _drawText;
  57172. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57173. protected _applyStates(context: CanvasRenderingContext2D): void;
  57174. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  57175. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  57176. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  57177. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  57178. protected _renderLines(context: CanvasRenderingContext2D): void;
  57179. /**
  57180. * Given a width constraint applied on the text block, find the expected height
  57181. * @returns expected height
  57182. */
  57183. computeExpectedHeight(): number;
  57184. dispose(): void;
  57185. }
  57186. }
  57187. declare module BABYLON.GUI {
  57188. /**
  57189. * Class used to create 2D images
  57190. */
  57191. export class Image extends Control {
  57192. name?: string | undefined;
  57193. private static _WorkingCanvas;
  57194. private _domImage;
  57195. private _imageWidth;
  57196. private _imageHeight;
  57197. private _loaded;
  57198. private _stretch;
  57199. private _source;
  57200. private _autoScale;
  57201. private _sourceLeft;
  57202. private _sourceTop;
  57203. private _sourceWidth;
  57204. private _sourceHeight;
  57205. private _cellWidth;
  57206. private _cellHeight;
  57207. private _cellId;
  57208. private _populateNinePatchSlicesFromImage;
  57209. private _sliceLeft;
  57210. private _sliceRight;
  57211. private _sliceTop;
  57212. private _sliceBottom;
  57213. private _detectPointerOnOpaqueOnly;
  57214. /**
  57215. * BABYLON.Observable notified when the content is loaded
  57216. */
  57217. onImageLoadedObservable: BABYLON.Observable<Image>;
  57218. /**
  57219. * Gets a boolean indicating that the content is loaded
  57220. */
  57221. readonly isLoaded: boolean;
  57222. /**
  57223. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  57224. */
  57225. populateNinePatchSlicesFromImage: boolean;
  57226. /**
  57227. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  57228. * Beware using this as this will comsume more memory as the image has to be stored twice
  57229. */
  57230. detectPointerOnOpaqueOnly: boolean;
  57231. /**
  57232. * Gets or sets the left value for slicing (9-patch)
  57233. */
  57234. sliceLeft: number;
  57235. /**
  57236. * Gets or sets the right value for slicing (9-patch)
  57237. */
  57238. sliceRight: number;
  57239. /**
  57240. * Gets or sets the top value for slicing (9-patch)
  57241. */
  57242. sliceTop: number;
  57243. /**
  57244. * Gets or sets the bottom value for slicing (9-patch)
  57245. */
  57246. sliceBottom: number;
  57247. /**
  57248. * Gets or sets the left coordinate in the source image
  57249. */
  57250. sourceLeft: number;
  57251. /**
  57252. * Gets or sets the top coordinate in the source image
  57253. */
  57254. sourceTop: number;
  57255. /**
  57256. * Gets or sets the width to capture in the source image
  57257. */
  57258. sourceWidth: number;
  57259. /**
  57260. * Gets or sets the height to capture in the source image
  57261. */
  57262. sourceHeight: number;
  57263. /**
  57264. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  57265. * @see http://doc.babylonjs.com/how_to/gui#image
  57266. */
  57267. autoScale: boolean;
  57268. /** Gets or sets the streching mode used by the image */
  57269. stretch: number;
  57270. /**
  57271. * Gets or sets the internal DOM image used to render the control
  57272. */
  57273. domImage: HTMLImageElement;
  57274. private _onImageLoaded;
  57275. private _extractNinePatchSliceDataFromImage;
  57276. /**
  57277. * Gets or sets image source url
  57278. */
  57279. source: BABYLON.Nullable<string>;
  57280. /**
  57281. * Gets or sets the cell width to use when animation sheet is enabled
  57282. * @see http://doc.babylonjs.com/how_to/gui#image
  57283. */
  57284. cellWidth: number;
  57285. /**
  57286. * Gets or sets the cell height to use when animation sheet is enabled
  57287. * @see http://doc.babylonjs.com/how_to/gui#image
  57288. */
  57289. cellHeight: number;
  57290. /**
  57291. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  57292. * @see http://doc.babylonjs.com/how_to/gui#image
  57293. */
  57294. cellId: number;
  57295. /**
  57296. * Creates a new Image
  57297. * @param name defines the control name
  57298. * @param url defines the image url
  57299. */
  57300. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  57301. /**
  57302. * Tests if a given coordinates belong to the current control
  57303. * @param x defines x coordinate to test
  57304. * @param y defines y coordinate to test
  57305. * @returns true if the coordinates are inside the control
  57306. */
  57307. contains(x: number, y: number): boolean;
  57308. protected _getTypeName(): string;
  57309. /** Force the control to synchronize with its content */
  57310. synchronizeSizeWithContent(): void;
  57311. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57312. private _prepareWorkingCanvasForOpaqueDetection;
  57313. private _drawImage; draw(context: CanvasRenderingContext2D): void;
  57314. private _renderCornerPatch;
  57315. private _renderNinePatch;
  57316. dispose(): void;
  57317. /** STRETCH_NONE */
  57318. static readonly STRETCH_NONE: number;
  57319. /** STRETCH_FILL */
  57320. static readonly STRETCH_FILL: number;
  57321. /** STRETCH_UNIFORM */
  57322. static readonly STRETCH_UNIFORM: number;
  57323. /** STRETCH_EXTEND */
  57324. static readonly STRETCH_EXTEND: number;
  57325. /** NINE_PATCH */
  57326. static readonly STRETCH_NINE_PATCH: number;
  57327. }
  57328. }
  57329. declare module BABYLON.GUI {
  57330. /**
  57331. * Class used to create 2D buttons
  57332. */
  57333. export class Button extends Rectangle {
  57334. name?: string | undefined;
  57335. /**
  57336. * Function called to generate a pointer enter animation
  57337. */
  57338. pointerEnterAnimation: () => void;
  57339. /**
  57340. * Function called to generate a pointer out animation
  57341. */
  57342. pointerOutAnimation: () => void;
  57343. /**
  57344. * Function called to generate a pointer down animation
  57345. */
  57346. pointerDownAnimation: () => void;
  57347. /**
  57348. * Function called to generate a pointer up animation
  57349. */
  57350. pointerUpAnimation: () => void;
  57351. private _image;
  57352. /**
  57353. * Returns the image part of the button (if any)
  57354. */
  57355. readonly image: BABYLON.Nullable<Image>;
  57356. private _textBlock;
  57357. /**
  57358. * Returns the image part of the button (if any)
  57359. */
  57360. readonly textBlock: BABYLON.Nullable<TextBlock>;
  57361. /**
  57362. * Creates a new Button
  57363. * @param name defines the name of the button
  57364. */
  57365. constructor(name?: string | undefined);
  57366. protected _getTypeName(): string;
  57367. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57368. /** @hidden */ onPointerEnter(target: Control): boolean;
  57369. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  57370. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57371. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57372. /**
  57373. * Creates a new button made with an image and a text
  57374. * @param name defines the name of the button
  57375. * @param text defines the text of the button
  57376. * @param imageUrl defines the url of the image
  57377. * @returns a new Button
  57378. */
  57379. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  57380. /**
  57381. * Creates a new button made with an image
  57382. * @param name defines the name of the button
  57383. * @param imageUrl defines the url of the image
  57384. * @returns a new Button
  57385. */
  57386. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  57387. /**
  57388. * Creates a new button made with a text
  57389. * @param name defines the name of the button
  57390. * @param text defines the text of the button
  57391. * @returns a new Button
  57392. */
  57393. static CreateSimpleButton(name: string, text: string): Button;
  57394. /**
  57395. * Creates a new button made with an image and a centered text
  57396. * @param name defines the name of the button
  57397. * @param text defines the text of the button
  57398. * @param imageUrl defines the url of the image
  57399. * @returns a new Button
  57400. */
  57401. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  57402. }
  57403. }
  57404. declare module BABYLON.GUI {
  57405. /**
  57406. * Class used to create a 2D stack panel container
  57407. */
  57408. export class StackPanel extends Container {
  57409. name?: string | undefined;
  57410. private _isVertical;
  57411. private _manualWidth;
  57412. private _manualHeight;
  57413. private _doNotTrackManualChanges;
  57414. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  57415. isVertical: boolean;
  57416. /**
  57417. * Gets or sets panel width.
  57418. * This value should not be set when in horizontal mode as it will be computed automatically
  57419. */
  57420. width: string | number;
  57421. /**
  57422. * Gets or sets panel height.
  57423. * This value should not be set when in vertical mode as it will be computed automatically
  57424. */
  57425. height: string | number;
  57426. /**
  57427. * Creates a new StackPanel
  57428. * @param name defines control name
  57429. */
  57430. constructor(name?: string | undefined);
  57431. protected _getTypeName(): string;
  57432. /** @hidden */
  57433. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57434. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57435. protected _postMeasure(): void;
  57436. }
  57437. }
  57438. declare module BABYLON.GUI {
  57439. /**
  57440. * Class used to represent a 2D checkbox
  57441. */
  57442. export class Checkbox extends Control {
  57443. name?: string | undefined;
  57444. private _isChecked;
  57445. private _background;
  57446. private _checkSizeRatio;
  57447. private _thickness;
  57448. /** Gets or sets border thickness */
  57449. thickness: number;
  57450. /**
  57451. * BABYLON.Observable raised when isChecked property changes
  57452. */
  57453. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  57454. /** Gets or sets a value indicating the ratio between overall size and check size */
  57455. checkSizeRatio: number;
  57456. /** Gets or sets background color */
  57457. background: string;
  57458. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  57459. isChecked: boolean;
  57460. /**
  57461. * Creates a new CheckBox
  57462. * @param name defines the control name
  57463. */
  57464. constructor(name?: string | undefined);
  57465. protected _getTypeName(): string;
  57466. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57467. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57468. /**
  57469. * Utility function to easily create a checkbox with a header
  57470. * @param title defines the label to use for the header
  57471. * @param onValueChanged defines the callback to call when value changes
  57472. * @returns a StackPanel containing the checkbox and a textBlock
  57473. */
  57474. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  57475. }
  57476. }
  57477. declare module BABYLON.GUI {
  57478. /**
  57479. * Class used to store key control properties
  57480. */
  57481. export class KeyPropertySet {
  57482. /** Width */
  57483. width?: string;
  57484. /** Height */
  57485. height?: string;
  57486. /** Left padding */
  57487. paddingLeft?: string;
  57488. /** Right padding */
  57489. paddingRight?: string;
  57490. /** Top padding */
  57491. paddingTop?: string;
  57492. /** Bottom padding */
  57493. paddingBottom?: string;
  57494. /** Foreground color */
  57495. color?: string;
  57496. /** Background color */
  57497. background?: string;
  57498. }
  57499. /**
  57500. * Class used to create virtual keyboard
  57501. */
  57502. export class VirtualKeyboard extends StackPanel {
  57503. /** BABYLON.Observable raised when a key is pressed */
  57504. onKeyPressObservable: BABYLON.Observable<string>;
  57505. /** Gets or sets default key button width */
  57506. defaultButtonWidth: string;
  57507. /** Gets or sets default key button height */
  57508. defaultButtonHeight: string;
  57509. /** Gets or sets default key button left padding */
  57510. defaultButtonPaddingLeft: string;
  57511. /** Gets or sets default key button right padding */
  57512. defaultButtonPaddingRight: string;
  57513. /** Gets or sets default key button top padding */
  57514. defaultButtonPaddingTop: string;
  57515. /** Gets or sets default key button bottom padding */
  57516. defaultButtonPaddingBottom: string;
  57517. /** Gets or sets default key button foreground color */
  57518. defaultButtonColor: string;
  57519. /** Gets or sets default key button background color */
  57520. defaultButtonBackground: string;
  57521. /** Gets or sets shift button foreground color */
  57522. shiftButtonColor: string;
  57523. /** Gets or sets shift button thickness*/
  57524. selectedShiftThickness: number;
  57525. /** Gets shift key state */
  57526. shiftState: number;
  57527. protected _getTypeName(): string;
  57528. private _createKey;
  57529. /**
  57530. * Adds a new row of keys
  57531. * @param keys defines the list of keys to add
  57532. * @param propertySets defines the associated property sets
  57533. */
  57534. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  57535. /**
  57536. * Set the shift key to a specific state
  57537. * @param shiftState defines the new shift state
  57538. */
  57539. applyShiftState(shiftState: number): void;
  57540. private _currentlyConnectedInputText;
  57541. private _connectedInputTexts;
  57542. private _onKeyPressObserver;
  57543. /** Gets the input text control currently attached to the keyboard */
  57544. readonly connectedInputText: BABYLON.Nullable<InputText>;
  57545. /**
  57546. * Connects the keyboard with an input text control
  57547. *
  57548. * @param input defines the target control
  57549. */
  57550. connect(input: InputText): void;
  57551. /**
  57552. * Disconnects the keyboard from connected InputText controls
  57553. *
  57554. * @param input optionally defines a target control, otherwise all are disconnected
  57555. */
  57556. disconnect(input?: InputText): void;
  57557. private _removeConnectedInputObservables;
  57558. /**
  57559. * Release all resources
  57560. */
  57561. dispose(): void;
  57562. /**
  57563. * Creates a new keyboard using a default layout
  57564. *
  57565. * @param name defines control name
  57566. * @returns a new VirtualKeyboard
  57567. */
  57568. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  57569. }
  57570. }
  57571. declare module BABYLON.GUI {
  57572. /**
  57573. * Class used to create input text control
  57574. */
  57575. export class InputText extends Control implements IFocusableControl {
  57576. name?: string | undefined;
  57577. private _text;
  57578. private _placeholderText;
  57579. private _background;
  57580. private _focusedBackground;
  57581. private _focusedColor;
  57582. private _placeholderColor;
  57583. private _thickness;
  57584. private _margin;
  57585. private _autoStretchWidth;
  57586. private _maxWidth;
  57587. private _isFocused;
  57588. private _blinkTimeout;
  57589. private _blinkIsEven;
  57590. private _cursorOffset;
  57591. private _scrollLeft;
  57592. private _textWidth;
  57593. private _clickedCoordinate;
  57594. private _deadKey;
  57595. private _addKey;
  57596. private _currentKey;
  57597. private _isTextHighlightOn;
  57598. private _textHighlightColor;
  57599. private _highligherOpacity;
  57600. private _highlightedText;
  57601. private _startHighlightIndex;
  57602. private _endHighlightIndex;
  57603. private _cursorIndex;
  57604. private _onFocusSelectAll;
  57605. private _isPointerDown;
  57606. private _onClipboardObserver;
  57607. private _onPointerDblTapObserver;
  57608. /** @hidden */ connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  57609. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  57610. promptMessage: string;
  57611. /** BABYLON.Observable raised when the text changes */
  57612. onTextChangedObservable: BABYLON.Observable<InputText>;
  57613. /** BABYLON.Observable raised just before an entered character is to be added */
  57614. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  57615. /** BABYLON.Observable raised when the control gets the focus */
  57616. onFocusObservable: BABYLON.Observable<InputText>;
  57617. /** BABYLON.Observable raised when the control loses the focus */
  57618. onBlurObservable: BABYLON.Observable<InputText>;
  57619. /**Observable raised when the text is highlighted */
  57620. onTextHighlightObservable: BABYLON.Observable<InputText>;
  57621. /**Observable raised when copy event is triggered */
  57622. onTextCopyObservable: BABYLON.Observable<InputText>;
  57623. /** BABYLON.Observable raised when cut event is triggered */
  57624. onTextCutObservable: BABYLON.Observable<InputText>;
  57625. /** BABYLON.Observable raised when paste event is triggered */
  57626. onTextPasteObservable: BABYLON.Observable<InputText>;
  57627. /** BABYLON.Observable raised when a key event was processed */
  57628. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  57629. /** Gets or sets the maximum width allowed by the control */
  57630. maxWidth: string | number;
  57631. /** Gets the maximum width allowed by the control in pixels */
  57632. readonly maxWidthInPixels: number;
  57633. /** Gets or sets the text highlighter transparency; default: 0.4 */
  57634. highligherOpacity: number;
  57635. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  57636. onFocusSelectAll: boolean;
  57637. /** Gets or sets the text hightlight color */
  57638. textHighlightColor: string;
  57639. /** Gets or sets control margin */
  57640. margin: string;
  57641. /** Gets control margin in pixels */
  57642. readonly marginInPixels: number;
  57643. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  57644. autoStretchWidth: boolean;
  57645. /** Gets or sets border thickness */
  57646. thickness: number;
  57647. /** Gets or sets the background color when focused */
  57648. focusedBackground: string;
  57649. /** Gets or sets the background color when focused */
  57650. focusedColor: string;
  57651. /** Gets or sets the background color */
  57652. background: string;
  57653. /** Gets or sets the placeholder color */
  57654. placeholderColor: string;
  57655. /** Gets or sets the text displayed when the control is empty */
  57656. placeholderText: string;
  57657. /** Gets or sets the dead key flag */
  57658. deadKey: boolean;
  57659. /** Gets or sets the highlight text */
  57660. highlightedText: string;
  57661. /** Gets or sets if the current key should be added */
  57662. addKey: boolean;
  57663. /** Gets or sets the value of the current key being entered */
  57664. currentKey: string;
  57665. /** Gets or sets the text displayed in the control */
  57666. text: string;
  57667. /** Gets or sets control width */
  57668. width: string | number;
  57669. /**
  57670. * Creates a new InputText
  57671. * @param name defines the control name
  57672. * @param text defines the text of the control
  57673. */
  57674. constructor(name?: string | undefined, text?: string);
  57675. /** @hidden */
  57676. onBlur(): void;
  57677. /** @hidden */
  57678. onFocus(): void;
  57679. protected _getTypeName(): string;
  57680. /**
  57681. * Function called to get the list of controls that should not steal the focus from this control
  57682. * @returns an array of controls
  57683. */
  57684. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  57685. /** @hidden */
  57686. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  57687. /** @hidden */
  57688. private _updateValueFromCursorIndex;
  57689. /** @hidden */
  57690. private _processDblClick;
  57691. /** @hidden */
  57692. private _selectAllText;
  57693. /**
  57694. * Handles the keyboard event
  57695. * @param evt Defines the KeyboardEvent
  57696. */
  57697. processKeyboard(evt: KeyboardEvent): void;
  57698. /** @hidden */
  57699. private _onCopyText;
  57700. /** @hidden */
  57701. private _onCutText;
  57702. /** @hidden */
  57703. private _onPasteText; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57704. protected _beforeRenderText(text: string): string;
  57705. dispose(): void;
  57706. }
  57707. }
  57708. declare module BABYLON.GUI {
  57709. /**
  57710. * Class used to create a 2D grid container
  57711. */
  57712. export class Grid extends Container {
  57713. name?: string | undefined;
  57714. private _rowDefinitions;
  57715. private _columnDefinitions;
  57716. private _cells;
  57717. private _childControls;
  57718. /**
  57719. * Gets the number of columns
  57720. */
  57721. readonly columnCount: number;
  57722. /**
  57723. * Gets the number of rows
  57724. */
  57725. readonly rowCount: number;
  57726. /** Gets the list of children */
  57727. readonly children: Control[];
  57728. /**
  57729. * Gets the definition of a specific row
  57730. * @param index defines the index of the row
  57731. * @returns the row definition
  57732. */
  57733. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  57734. /**
  57735. * Gets the definition of a specific column
  57736. * @param index defines the index of the column
  57737. * @returns the column definition
  57738. */
  57739. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  57740. /**
  57741. * Adds a new row to the grid
  57742. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  57743. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  57744. * @returns the current grid
  57745. */
  57746. addRowDefinition(height: number, isPixel?: boolean): Grid;
  57747. /**
  57748. * Adds a new column to the grid
  57749. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  57750. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  57751. * @returns the current grid
  57752. */
  57753. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  57754. /**
  57755. * Update a row definition
  57756. * @param index defines the index of the row to update
  57757. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  57758. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  57759. * @returns the current grid
  57760. */
  57761. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  57762. /**
  57763. * Update a column definition
  57764. * @param index defines the index of the column to update
  57765. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  57766. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  57767. * @returns the current grid
  57768. */
  57769. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  57770. /**
  57771. * Gets the list of children stored in a specific cell
  57772. * @param row defines the row to check
  57773. * @param column defines the column to check
  57774. * @returns the list of controls
  57775. */
  57776. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  57777. /**
  57778. * Gets a string representing the child cell info (row x column)
  57779. * @param child defines the control to get info from
  57780. * @returns a string containing the child cell info (row x column)
  57781. */
  57782. getChildCellInfo(child: Control): string;
  57783. private _removeCell;
  57784. private _offsetCell;
  57785. /**
  57786. * Remove a column definition at specified index
  57787. * @param index defines the index of the column to remove
  57788. * @returns the current grid
  57789. */
  57790. removeColumnDefinition(index: number): Grid;
  57791. /**
  57792. * Remove a row definition at specified index
  57793. * @param index defines the index of the row to remove
  57794. * @returns the current grid
  57795. */
  57796. removeRowDefinition(index: number): Grid;
  57797. /**
  57798. * Adds a new control to the current grid
  57799. * @param control defines the control to add
  57800. * @param row defines the row where to add the control (0 by default)
  57801. * @param column defines the column where to add the control (0 by default)
  57802. * @returns the current grid
  57803. */
  57804. addControl(control: Control, row?: number, column?: number): Grid;
  57805. /**
  57806. * Removes a control from the current container
  57807. * @param control defines the control to remove
  57808. * @returns the current container
  57809. */
  57810. removeControl(control: Control): Container;
  57811. /**
  57812. * Creates a new Grid
  57813. * @param name defines control name
  57814. */
  57815. constructor(name?: string | undefined);
  57816. protected _getTypeName(): string;
  57817. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  57818. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; flagDescendantsAsMatrixDirty(): void; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  57819. /** Releases associated resources */
  57820. dispose(): void;
  57821. }
  57822. }
  57823. declare module BABYLON.GUI {
  57824. /** Class used to create color pickers */
  57825. export class ColorPicker extends Control {
  57826. name?: string | undefined;
  57827. private static _Epsilon;
  57828. private _colorWheelCanvas;
  57829. private _value;
  57830. private _tmpColor;
  57831. private _pointerStartedOnSquare;
  57832. private _pointerStartedOnWheel;
  57833. private _squareLeft;
  57834. private _squareTop;
  57835. private _squareSize;
  57836. private _h;
  57837. private _s;
  57838. private _v;
  57839. /**
  57840. * BABYLON.Observable raised when the value changes
  57841. */
  57842. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  57843. /** Gets or sets the color of the color picker */
  57844. value: BABYLON.Color3;
  57845. /**
  57846. * Gets or sets control width
  57847. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57848. */
  57849. width: string | number;
  57850. /**
  57851. * Gets or sets control height
  57852. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57853. */
  57854. /** Gets or sets control height */
  57855. height: string | number;
  57856. /** Gets or sets control size */
  57857. size: string | number;
  57858. /**
  57859. * Creates a new ColorPicker
  57860. * @param name defines the control name
  57861. */
  57862. constructor(name?: string | undefined);
  57863. protected _getTypeName(): string;
  57864. /** @hidden */
  57865. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57866. private _updateSquareProps;
  57867. private _drawGradientSquare;
  57868. private _drawCircle;
  57869. private _createColorWheelCanvas;
  57870. private _RGBtoHSV;
  57871. private _HSVtoRGB;
  57872. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57873. private _pointerIsDown;
  57874. private _updateValueFromPointer;
  57875. private _isPointOnSquare;
  57876. private _isPointOnWheel; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57877. /**
  57878. * This function expands the color picker by creating a color picker dialog with manual
  57879. * color value input and the ability to save colors into an array to be used later in
  57880. * subsequent launches of the dialogue.
  57881. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  57882. * @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
  57883. * @returns picked color as a hex string and the saved colors array as hex strings.
  57884. */
  57885. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  57886. pickerWidth?: string;
  57887. pickerHeight?: string;
  57888. headerHeight?: string;
  57889. lastColor?: string;
  57890. swatchLimit?: number;
  57891. numSwatchesPerLine?: number;
  57892. savedColors?: Array<string>;
  57893. }): Promise<{
  57894. savedColors?: string[];
  57895. pickedColor: string;
  57896. }>;
  57897. }
  57898. }
  57899. declare module BABYLON.GUI {
  57900. /** Class used to create 2D ellipse containers */
  57901. export class Ellipse extends Container {
  57902. name?: string | undefined;
  57903. private _thickness;
  57904. /** Gets or sets border thickness */
  57905. thickness: number;
  57906. /**
  57907. * Creates a new Ellipse
  57908. * @param name defines the control name
  57909. */
  57910. constructor(name?: string | undefined);
  57911. protected _getTypeName(): string;
  57912. protected _localDraw(context: CanvasRenderingContext2D): void;
  57913. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57914. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  57915. }
  57916. }
  57917. declare module BABYLON.GUI {
  57918. /**
  57919. * Class used to create a password control
  57920. */
  57921. export class InputPassword extends InputText {
  57922. protected _beforeRenderText(text: string): string;
  57923. }
  57924. }
  57925. declare module BABYLON.GUI {
  57926. /** Class used to render 2D lines */
  57927. export class Line extends Control {
  57928. name?: string | undefined;
  57929. private _lineWidth;
  57930. private _x1;
  57931. private _y1;
  57932. private _x2;
  57933. private _y2;
  57934. private _dash;
  57935. private _connectedControl;
  57936. private _connectedControlDirtyObserver;
  57937. /** Gets or sets the dash pattern */
  57938. dash: Array<number>;
  57939. /** Gets or sets the control connected with the line end */
  57940. connectedControl: Control;
  57941. /** Gets or sets start coordinates on X axis */
  57942. x1: string | number;
  57943. /** Gets or sets start coordinates on Y axis */
  57944. y1: string | number;
  57945. /** Gets or sets end coordinates on X axis */
  57946. x2: string | number;
  57947. /** Gets or sets end coordinates on Y axis */
  57948. y2: string | number;
  57949. /** Gets or sets line width */
  57950. lineWidth: number;
  57951. /** Gets or sets horizontal alignment */
  57952. horizontalAlignment: number;
  57953. /** Gets or sets vertical alignment */
  57954. verticalAlignment: number;
  57955. private readonly _effectiveX2;
  57956. private readonly _effectiveY2;
  57957. /**
  57958. * Creates a new Line
  57959. * @param name defines the control name
  57960. */
  57961. constructor(name?: string | undefined);
  57962. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; measure(): void;
  57963. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57964. /**
  57965. * Move one end of the line given 3D cartesian coordinates.
  57966. * @param position Targeted world position
  57967. * @param scene BABYLON.Scene
  57968. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  57969. */
  57970. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  57971. /**
  57972. * Move one end of the line to a position in screen absolute space.
  57973. * @param projectedPosition Position in screen absolute space (X, Y)
  57974. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  57975. */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  57976. }
  57977. }
  57978. declare module BABYLON.GUI {
  57979. /**
  57980. * Class used to store a point for a MultiLine object.
  57981. * The point can be pure 2D coordinates, a mesh or a control
  57982. */
  57983. export class MultiLinePoint {
  57984. private _multiLine;
  57985. private _x;
  57986. private _y;
  57987. private _control;
  57988. private _mesh;
  57989. private _controlObserver;
  57990. private _meshObserver;
  57991. /** @hidden */ point: BABYLON.Vector2;
  57992. /**
  57993. * Creates a new MultiLinePoint
  57994. * @param multiLine defines the source MultiLine object
  57995. */
  57996. constructor(multiLine: MultiLine);
  57997. /** Gets or sets x coordinate */
  57998. x: string | number;
  57999. /** Gets or sets y coordinate */
  58000. y: string | number;
  58001. /** Gets or sets the control associated with this point */
  58002. control: BABYLON.Nullable<Control>;
  58003. /** Gets or sets the mesh associated with this point */
  58004. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  58005. /** Resets links */
  58006. resetLinks(): void;
  58007. /**
  58008. * Gets a translation vector
  58009. * @returns the translation vector
  58010. */
  58011. translate(): BABYLON.Vector2;
  58012. private _translatePoint;
  58013. /** Release associated resources */
  58014. dispose(): void;
  58015. }
  58016. }
  58017. declare module BABYLON.GUI {
  58018. /**
  58019. * Class used to create multi line control
  58020. */
  58021. export class MultiLine extends Control {
  58022. name?: string | undefined;
  58023. private _lineWidth;
  58024. private _dash;
  58025. private _points;
  58026. private _minX;
  58027. private _minY;
  58028. private _maxX;
  58029. private _maxY;
  58030. /**
  58031. * Creates a new MultiLine
  58032. * @param name defines the control name
  58033. */
  58034. constructor(name?: string | undefined);
  58035. /** Gets or sets dash pattern */
  58036. dash: Array<number>;
  58037. /**
  58038. * Gets point stored at specified index
  58039. * @param index defines the index to look for
  58040. * @returns the requested point if found
  58041. */
  58042. getAt(index: number): MultiLinePoint;
  58043. /** Function called when a point is updated */
  58044. onPointUpdate: () => void;
  58045. /**
  58046. * Adds new points to the point collection
  58047. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  58048. * @returns the list of created MultiLinePoint
  58049. */
  58050. add(...items: (AbstractMesh | Control | {
  58051. x: string | number;
  58052. y: string | number;
  58053. })[]): MultiLinePoint[];
  58054. /**
  58055. * Adds a new point to the point collection
  58056. * @param item defines the item (mesh, control or 2d coordiantes) to add
  58057. * @returns the created MultiLinePoint
  58058. */
  58059. push(item?: (AbstractMesh | Control | {
  58060. x: string | number;
  58061. y: string | number;
  58062. })): MultiLinePoint;
  58063. /**
  58064. * Remove a specific value or point from the active point collection
  58065. * @param value defines the value or point to remove
  58066. */
  58067. remove(value: number | MultiLinePoint): void;
  58068. /**
  58069. * Resets this object to initial state (no point)
  58070. */
  58071. reset(): void;
  58072. /**
  58073. * Resets all links
  58074. */
  58075. resetLinks(): void;
  58076. /** Gets or sets line width */
  58077. lineWidth: number;
  58078. horizontalAlignment: number;
  58079. verticalAlignment: number;
  58080. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58081. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; measure(): void;
  58082. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58083. dispose(): void;
  58084. }
  58085. }
  58086. declare module BABYLON.GUI {
  58087. /**
  58088. * Class used to create radio button controls
  58089. */
  58090. export class RadioButton extends Control {
  58091. name?: string | undefined;
  58092. private _isChecked;
  58093. private _background;
  58094. private _checkSizeRatio;
  58095. private _thickness;
  58096. /** Gets or sets border thickness */
  58097. thickness: number;
  58098. /** Gets or sets group name */
  58099. group: string;
  58100. /** BABYLON.Observable raised when isChecked is changed */
  58101. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  58102. /** Gets or sets a value indicating the ratio between overall size and check size */
  58103. checkSizeRatio: number;
  58104. /** Gets or sets background color */
  58105. background: string;
  58106. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  58107. isChecked: boolean;
  58108. /**
  58109. * Creates a new RadioButton
  58110. * @param name defines the control name
  58111. */
  58112. constructor(name?: string | undefined);
  58113. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  58114. /**
  58115. * Utility function to easily create a radio button with a header
  58116. * @param title defines the label to use for the header
  58117. * @param group defines the group to use for the radio button
  58118. * @param isChecked defines the initial state of the radio button
  58119. * @param onValueChanged defines the callback to call when value changes
  58120. * @returns a StackPanel containing the radio button and a textBlock
  58121. */
  58122. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  58123. }
  58124. }
  58125. declare module BABYLON.GUI {
  58126. /**
  58127. * Class used to create slider controls
  58128. */
  58129. export class BaseSlider extends Control {
  58130. name?: string | undefined;
  58131. protected _thumbWidth: ValueAndUnit;
  58132. private _minimum;
  58133. private _maximum;
  58134. private _value;
  58135. private _isVertical;
  58136. protected _barOffset: ValueAndUnit;
  58137. private _isThumbClamped;
  58138. protected _displayThumb: boolean;
  58139. private _step;
  58140. protected _effectiveBarOffset: number;
  58141. protected _renderLeft: number;
  58142. protected _renderTop: number;
  58143. protected _renderWidth: number;
  58144. protected _renderHeight: number;
  58145. protected _backgroundBoxLength: number;
  58146. protected _backgroundBoxThickness: number;
  58147. protected _effectiveThumbThickness: number;
  58148. /** BABYLON.Observable raised when the sldier value changes */
  58149. onValueChangedObservable: BABYLON.Observable<number>;
  58150. /** Gets or sets a boolean indicating if the thumb must be rendered */
  58151. displayThumb: boolean;
  58152. /** Gets or sets a step to apply to values (0 by default) */
  58153. step: number;
  58154. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  58155. barOffset: string | number;
  58156. /** Gets main bar offset in pixels*/
  58157. readonly barOffsetInPixels: number;
  58158. /** Gets or sets thumb width */
  58159. thumbWidth: string | number;
  58160. /** Gets thumb width in pixels */
  58161. readonly thumbWidthInPixels: number;
  58162. /** Gets or sets minimum value */
  58163. minimum: number;
  58164. /** Gets or sets maximum value */
  58165. maximum: number;
  58166. /** Gets or sets current value */
  58167. value: number;
  58168. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  58169. isVertical: boolean;
  58170. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  58171. isThumbClamped: boolean;
  58172. /**
  58173. * Creates a new BaseSlider
  58174. * @param name defines the control name
  58175. */
  58176. constructor(name?: string | undefined);
  58177. protected _getTypeName(): string;
  58178. protected _getThumbPosition(): number;
  58179. protected _getThumbThickness(type: string): number;
  58180. protected _prepareRenderingData(type: string): void;
  58181. private _pointerIsDown;
  58182. /** @hidden */
  58183. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  58184. }
  58185. }
  58186. declare module BABYLON.GUI {
  58187. /**
  58188. * Class used to create slider controls
  58189. */
  58190. export class Slider extends BaseSlider {
  58191. name?: string | undefined;
  58192. private _background;
  58193. private _borderColor;
  58194. private _isThumbCircle;
  58195. protected _displayValueBar: boolean;
  58196. /** Gets or sets a boolean indicating if the value bar must be rendered */
  58197. displayValueBar: boolean;
  58198. /** Gets or sets border color */
  58199. borderColor: string;
  58200. /** Gets or sets background color */
  58201. background: string;
  58202. /** Gets or sets a boolean indicating if the thumb should be round or square */
  58203. isThumbCircle: boolean;
  58204. /**
  58205. * Creates a new Slider
  58206. * @param name defines the control name
  58207. */
  58208. constructor(name?: string | undefined);
  58209. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58210. }
  58211. }
  58212. declare module BABYLON.GUI {
  58213. /** Class used to create a RadioGroup
  58214. * which contains groups of radio buttons
  58215. */
  58216. export class SelectorGroup {
  58217. /** name of SelectorGroup */
  58218. name: string;
  58219. private _groupPanel;
  58220. private _selectors;
  58221. private _groupHeader;
  58222. /**
  58223. * Creates a new SelectorGroup
  58224. * @param name of group, used as a group heading
  58225. */
  58226. constructor(
  58227. /** name of SelectorGroup */
  58228. name: string);
  58229. /** Gets the groupPanel of the SelectorGroup */
  58230. readonly groupPanel: StackPanel;
  58231. /** Gets the selectors array */
  58232. readonly selectors: StackPanel[];
  58233. /** Gets and sets the group header */
  58234. header: string;
  58235. /** @hidden */
  58236. private _addGroupHeader;
  58237. /** @hidden*/ getSelector(selectorNb: number): StackPanel | undefined;
  58238. /** Removes the selector at the given position
  58239. * @param selectorNb the position of the selector within the group
  58240. */
  58241. removeSelector(selectorNb: number): void;
  58242. }
  58243. /** Class used to create a CheckboxGroup
  58244. * which contains groups of checkbox buttons
  58245. */
  58246. export class CheckboxGroup extends SelectorGroup {
  58247. /** Adds a checkbox as a control
  58248. * @param text is the label for the selector
  58249. * @param func is the function called when the Selector is checked
  58250. * @param checked is true when Selector is checked
  58251. */
  58252. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  58253. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58254. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58255. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58256. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58257. }
  58258. /** Class used to create a RadioGroup
  58259. * which contains groups of radio buttons
  58260. */
  58261. export class RadioGroup extends SelectorGroup {
  58262. private _selectNb;
  58263. /** Adds a radio button as a control
  58264. * @param label is the label for the selector
  58265. * @param func is the function called when the Selector is checked
  58266. * @param checked is true when Selector is checked
  58267. */
  58268. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  58269. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58270. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58271. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58272. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58273. }
  58274. /** Class used to create a SliderGroup
  58275. * which contains groups of slider buttons
  58276. */
  58277. export class SliderGroup extends SelectorGroup {
  58278. /**
  58279. * Adds a slider to the SelectorGroup
  58280. * @param label is the label for the SliderBar
  58281. * @param func is the function called when the Slider moves
  58282. * @param unit is a string describing the units used, eg degrees or metres
  58283. * @param min is the minimum value for the Slider
  58284. * @param max is the maximum value for the Slider
  58285. * @param value is the start value for the Slider between min and max
  58286. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  58287. */
  58288. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  58289. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58290. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58291. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58292. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58293. }
  58294. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  58295. * @see http://doc.babylonjs.com/how_to/selector
  58296. */
  58297. export class SelectionPanel extends Rectangle {
  58298. /** name of SelectionPanel */
  58299. name: string;
  58300. /** an array of SelectionGroups */
  58301. groups: SelectorGroup[];
  58302. private _panel;
  58303. private _buttonColor;
  58304. private _buttonBackground;
  58305. private _headerColor;
  58306. private _barColor;
  58307. private _barHeight;
  58308. private _spacerHeight;
  58309. private _labelColor;
  58310. private _groups;
  58311. private _bars;
  58312. /**
  58313. * Creates a new SelectionPanel
  58314. * @param name of SelectionPanel
  58315. * @param groups is an array of SelectionGroups
  58316. */
  58317. constructor(
  58318. /** name of SelectionPanel */
  58319. name: string,
  58320. /** an array of SelectionGroups */
  58321. groups?: SelectorGroup[]);
  58322. protected _getTypeName(): string;
  58323. /** Gets or sets the headerColor */
  58324. headerColor: string;
  58325. private _setHeaderColor;
  58326. /** Gets or sets the button color */
  58327. buttonColor: string;
  58328. private _setbuttonColor;
  58329. /** Gets or sets the label color */
  58330. labelColor: string;
  58331. private _setLabelColor;
  58332. /** Gets or sets the button background */
  58333. buttonBackground: string;
  58334. private _setButtonBackground;
  58335. /** Gets or sets the color of separator bar */
  58336. barColor: string;
  58337. private _setBarColor;
  58338. /** Gets or sets the height of separator bar */
  58339. barHeight: string;
  58340. private _setBarHeight;
  58341. /** Gets or sets the height of spacers*/
  58342. spacerHeight: string;
  58343. private _setSpacerHeight;
  58344. /** Adds a bar between groups */
  58345. private _addSpacer;
  58346. /** Add a group to the selection panel
  58347. * @param group is the selector group to add
  58348. */
  58349. addGroup(group: SelectorGroup): void;
  58350. /** Remove the group from the given position
  58351. * @param groupNb is the position of the group in the list
  58352. */
  58353. removeGroup(groupNb: number): void;
  58354. /** Change a group header label
  58355. * @param label is the new group header label
  58356. * @param groupNb is the number of the group to relabel
  58357. * */
  58358. setHeaderName(label: string, groupNb: number): void;
  58359. /** Change selector label to the one given
  58360. * @param label is the new selector label
  58361. * @param groupNb is the number of the groupcontaining the selector
  58362. * @param selectorNb is the number of the selector within a group to relabel
  58363. * */
  58364. relabel(label: string, groupNb: number, selectorNb: number): void;
  58365. /** For a given group position remove the selector at the given position
  58366. * @param groupNb is the number of the group to remove the selector from
  58367. * @param selectorNb is the number of the selector within the group
  58368. */
  58369. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  58370. /** For a given group position of correct type add a checkbox button
  58371. * @param groupNb is the number of the group to remove the selector from
  58372. * @param label is the label for the selector
  58373. * @param func is the function called when the Selector is checked
  58374. * @param checked is true when Selector is checked
  58375. */
  58376. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  58377. /** For a given group position of correct type add a radio button
  58378. * @param groupNb is the number of the group to remove the selector from
  58379. * @param label is the label for the selector
  58380. * @param func is the function called when the Selector is checked
  58381. * @param checked is true when Selector is checked
  58382. */
  58383. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  58384. /**
  58385. * For a given slider group add a slider
  58386. * @param groupNb is the number of the group to add the slider to
  58387. * @param label is the label for the Slider
  58388. * @param func is the function called when the Slider moves
  58389. * @param unit is a string describing the units used, eg degrees or metres
  58390. * @param min is the minimum value for the Slider
  58391. * @param max is the maximum value for the Slider
  58392. * @param value is the start value for the Slider between min and max
  58393. * @param onVal is the function used to format the value displayed, eg radians to degrees
  58394. */
  58395. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  58396. }
  58397. }
  58398. declare module BABYLON.GUI {
  58399. /**
  58400. * Class used to hold a the container for ScrollViewer
  58401. * @hidden
  58402. */
  58403. export class _ScrollViewerWindow extends Container {
  58404. parentClientWidth: number;
  58405. parentClientHeight: number;
  58406. /**
  58407. * Creates a new ScrollViewerWindow
  58408. * @param name of ScrollViewerWindow
  58409. */
  58410. constructor(name?: string);
  58411. protected _getTypeName(): string;
  58412. /** @hidden */
  58413. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58414. protected _postMeasure(): void;
  58415. }
  58416. }
  58417. declare module BABYLON.GUI {
  58418. /**
  58419. * Class used to create slider controls
  58420. */
  58421. export class ScrollBar extends BaseSlider {
  58422. name?: string | undefined;
  58423. private _background;
  58424. private _borderColor;
  58425. private _thumbMeasure;
  58426. /** Gets or sets border color */
  58427. borderColor: string;
  58428. /** Gets or sets background color */
  58429. background: string;
  58430. /**
  58431. * Creates a new Slider
  58432. * @param name defines the control name
  58433. */
  58434. constructor(name?: string | undefined);
  58435. protected _getTypeName(): string;
  58436. protected _getThumbThickness(): number; draw(context: CanvasRenderingContext2D): void;
  58437. private _first;
  58438. private _originX;
  58439. private _originY;
  58440. /** @hidden */
  58441. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  58442. }
  58443. }
  58444. declare module BABYLON.GUI {
  58445. /**
  58446. * Class used to hold a viewer window and sliders in a grid
  58447. */
  58448. export class ScrollViewer extends Rectangle {
  58449. private _grid;
  58450. private _horizontalBarSpace;
  58451. private _verticalBarSpace;
  58452. private _dragSpace;
  58453. private _horizontalBar;
  58454. private _verticalBar;
  58455. private _barColor;
  58456. private _barBackground;
  58457. private _barSize;
  58458. private _endLeft;
  58459. private _endTop;
  58460. private _window;
  58461. private _pointerIsOver;
  58462. private _wheelPrecision;
  58463. private _onPointerObserver;
  58464. private _clientWidth;
  58465. private _clientHeight;
  58466. /**
  58467. * Gets the horizontal scrollbar
  58468. */
  58469. readonly horizontalBar: ScrollBar;
  58470. /**
  58471. * Gets the vertical scrollbar
  58472. */
  58473. readonly verticalBar: ScrollBar;
  58474. /**
  58475. * Adds a new control to the current container
  58476. * @param control defines the control to add
  58477. * @returns the current container
  58478. */
  58479. addControl(control: BABYLON.Nullable<Control>): Container;
  58480. /**
  58481. * Removes a control from the current container
  58482. * @param control defines the control to remove
  58483. * @returns the current container
  58484. */
  58485. removeControl(control: Control): Container;
  58486. /** Gets the list of children */
  58487. readonly children: Control[]; flagDescendantsAsMatrixDirty(): void;
  58488. /**
  58489. * Creates a new ScrollViewer
  58490. * @param name of ScrollViewer
  58491. */
  58492. constructor(name?: string);
  58493. /** Reset the scroll viewer window to initial size */
  58494. resetWindow(): void;
  58495. protected _getTypeName(): string;
  58496. private _buildClientSizes;
  58497. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58498. protected _postMeasure(): void;
  58499. /**
  58500. * Gets or sets the mouse wheel precision
  58501. * from 0 to 1 with a default value of 0.05
  58502. * */
  58503. wheelPrecision: number;
  58504. /** Gets or sets the bar color */
  58505. barColor: string;
  58506. /** Gets or sets the size of the bar */
  58507. barSize: number;
  58508. /** Gets or sets the bar background */
  58509. barBackground: string;
  58510. /** @hidden */
  58511. private _updateScroller; link(host: AdvancedDynamicTexture): void;
  58512. /** @hidden */
  58513. private _attachWheel; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  58514. /** Releases associated resources */
  58515. dispose(): void;
  58516. }
  58517. }
  58518. declare module BABYLON.GUI {
  58519. /** Class used to render a grid */
  58520. export class DisplayGrid extends Control {
  58521. name?: string | undefined;
  58522. private _cellWidth;
  58523. private _cellHeight;
  58524. private _minorLineTickness;
  58525. private _minorLineColor;
  58526. private _majorLineTickness;
  58527. private _majorLineColor;
  58528. private _majorLineFrequency;
  58529. private _background;
  58530. private _displayMajorLines;
  58531. private _displayMinorLines;
  58532. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  58533. displayMinorLines: boolean;
  58534. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  58535. displayMajorLines: boolean;
  58536. /** Gets or sets background color (Black by default) */
  58537. background: string;
  58538. /** Gets or sets the width of each cell (20 by default) */
  58539. cellWidth: number;
  58540. /** Gets or sets the height of each cell (20 by default) */
  58541. cellHeight: number;
  58542. /** Gets or sets the tickness of minor lines (1 by default) */
  58543. minorLineTickness: number;
  58544. /** Gets or sets the color of minor lines (DarkGray by default) */
  58545. minorLineColor: string;
  58546. /** Gets or sets the tickness of major lines (2 by default) */
  58547. majorLineTickness: number;
  58548. /** Gets or sets the color of major lines (White by default) */
  58549. majorLineColor: string;
  58550. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  58551. majorLineFrequency: number;
  58552. /**
  58553. * Creates a new GridDisplayRectangle
  58554. * @param name defines the control name
  58555. */
  58556. constructor(name?: string | undefined); draw(context: CanvasRenderingContext2D): void;
  58557. protected _getTypeName(): string;
  58558. }
  58559. }
  58560. declare module BABYLON.GUI {
  58561. /**
  58562. * Class used to create slider controls based on images
  58563. */
  58564. export class ImageBasedSlider extends BaseSlider {
  58565. name?: string | undefined;
  58566. private _backgroundImage;
  58567. private _thumbImage;
  58568. private _valueBarImage;
  58569. private _tempMeasure;
  58570. displayThumb: boolean;
  58571. /**
  58572. * Gets or sets the image used to render the background
  58573. */
  58574. backgroundImage: Image;
  58575. /**
  58576. * Gets or sets the image used to render the value bar
  58577. */
  58578. valueBarImage: Image;
  58579. /**
  58580. * Gets or sets the image used to render the thumb
  58581. */
  58582. thumbImage: Image;
  58583. /**
  58584. * Creates a new ImageBasedSlider
  58585. * @param name defines the control name
  58586. */
  58587. constructor(name?: string | undefined);
  58588. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58589. }
  58590. }
  58591. declare module BABYLON.GUI {
  58592. /**
  58593. * Forcing an export so that this code will execute
  58594. * @hidden
  58595. */
  58596. const name = "Statics";
  58597. }
  58598. declare module BABYLON.GUI {
  58599. /**
  58600. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  58601. */
  58602. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  58603. /**
  58604. * Define the instrumented AdvancedDynamicTexture.
  58605. */
  58606. texture: AdvancedDynamicTexture;
  58607. private _captureRenderTime;
  58608. private _renderTime;
  58609. private _captureLayoutTime;
  58610. private _layoutTime;
  58611. private _onBeginRenderObserver;
  58612. private _onEndRenderObserver;
  58613. private _onBeginLayoutObserver;
  58614. private _onEndLayoutObserver;
  58615. /**
  58616. * Gets the perf counter used to capture render time
  58617. */
  58618. readonly renderTimeCounter: BABYLON.PerfCounter;
  58619. /**
  58620. * Gets the perf counter used to capture layout time
  58621. */
  58622. readonly layoutTimeCounter: BABYLON.PerfCounter;
  58623. /**
  58624. * Enable or disable the render time capture
  58625. */
  58626. captureRenderTime: boolean;
  58627. /**
  58628. * Enable or disable the layout time capture
  58629. */
  58630. captureLayoutTime: boolean;
  58631. /**
  58632. * Instantiates a new advanced dynamic texture instrumentation.
  58633. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  58634. * @param texture Defines the AdvancedDynamicTexture to instrument
  58635. */
  58636. constructor(
  58637. /**
  58638. * Define the instrumented AdvancedDynamicTexture.
  58639. */
  58640. texture: AdvancedDynamicTexture);
  58641. /**
  58642. * Dispose and release associated resources.
  58643. */
  58644. dispose(): void;
  58645. }
  58646. }
  58647. declare module BABYLON.GUI {
  58648. /**
  58649. * Class used to create containers for controls
  58650. */
  58651. export class Container3D extends Control3D {
  58652. private _blockLayout;
  58653. /**
  58654. * Gets the list of child controls
  58655. */
  58656. protected _children: Control3D[];
  58657. /**
  58658. * Gets the list of child controls
  58659. */
  58660. readonly children: Array<Control3D>;
  58661. /**
  58662. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  58663. * This is helpful to optimize layout operation when adding multiple children in a row
  58664. */
  58665. blockLayout: boolean;
  58666. /**
  58667. * Creates a new container
  58668. * @param name defines the container name
  58669. */
  58670. constructor(name?: string);
  58671. /**
  58672. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  58673. * @returns the current container
  58674. */
  58675. updateLayout(): Container3D;
  58676. /**
  58677. * Gets a boolean indicating if the given control is in the children of this control
  58678. * @param control defines the control to check
  58679. * @returns true if the control is in the child list
  58680. */
  58681. containsControl(control: Control3D): boolean;
  58682. /**
  58683. * Adds a control to the children of this control
  58684. * @param control defines the control to add
  58685. * @returns the current container
  58686. */
  58687. addControl(control: Control3D): Container3D;
  58688. /**
  58689. * This function will be called everytime a new control is added
  58690. */
  58691. protected _arrangeChildren(): void;
  58692. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  58693. /**
  58694. * Removes a control from the children of this control
  58695. * @param control defines the control to remove
  58696. * @returns the current container
  58697. */
  58698. removeControl(control: Control3D): Container3D;
  58699. protected _getTypeName(): string;
  58700. /**
  58701. * Releases all associated resources
  58702. */
  58703. dispose(): void;
  58704. /** Control rotation will remain unchanged */
  58705. static readonly UNSET_ORIENTATION: number;
  58706. /** Control will rotate to make it look at sphere central axis */
  58707. static readonly FACEORIGIN_ORIENTATION: number;
  58708. /** Control will rotate to make it look back at sphere central axis */
  58709. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  58710. /** Control will rotate to look at z axis (0, 0, 1) */
  58711. static readonly FACEFORWARD_ORIENTATION: number;
  58712. /** Control will rotate to look at negative z axis (0, 0, -1) */
  58713. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  58714. }
  58715. }
  58716. declare module BABYLON.GUI {
  58717. /**
  58718. * Class used to manage 3D user interface
  58719. * @see http://doc.babylonjs.com/how_to/gui3d
  58720. */
  58721. export class GUI3DManager implements BABYLON.IDisposable {
  58722. private _scene;
  58723. private _sceneDisposeObserver;
  58724. private _utilityLayer;
  58725. private _rootContainer;
  58726. private _pointerObserver;
  58727. private _pointerOutObserver;
  58728. /** @hidden */ lastPickedControl: Control3D;
  58729. /** @hidden */ lastControlOver: {
  58730. [pointerId: number]: Control3D;
  58731. };
  58732. /** @hidden */ lastControlDown: {
  58733. [pointerId: number]: Control3D;
  58734. };
  58735. /**
  58736. * BABYLON.Observable raised when the point picked by the pointer events changed
  58737. */
  58738. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  58739. /** @hidden */ sharedMaterials: {
  58740. [key: string]: BABYLON.Material;
  58741. };
  58742. /** Gets the hosting scene */
  58743. readonly scene: BABYLON.Scene;
  58744. /** Gets associated utility layer */
  58745. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  58746. /**
  58747. * Creates a new GUI3DManager
  58748. * @param scene
  58749. */
  58750. constructor(scene?: BABYLON.Scene);
  58751. private _handlePointerOut;
  58752. private _doPicking;
  58753. /**
  58754. * Gets the root container
  58755. */
  58756. readonly rootContainer: Container3D;
  58757. /**
  58758. * Gets a boolean indicating if the given control is in the root child list
  58759. * @param control defines the control to check
  58760. * @returns true if the control is in the root child list
  58761. */
  58762. containsControl(control: Control3D): boolean;
  58763. /**
  58764. * Adds a control to the root child list
  58765. * @param control defines the control to add
  58766. * @returns the current manager
  58767. */
  58768. addControl(control: Control3D): GUI3DManager;
  58769. /**
  58770. * Removes a control from the root child list
  58771. * @param control defines the control to remove
  58772. * @returns the current container
  58773. */
  58774. removeControl(control: Control3D): GUI3DManager;
  58775. /**
  58776. * Releases all associated resources
  58777. */
  58778. dispose(): void;
  58779. }
  58780. }
  58781. declare module BABYLON.GUI {
  58782. /**
  58783. * Class used to transport BABYLON.Vector3 information for pointer events
  58784. */
  58785. export class Vector3WithInfo extends BABYLON.Vector3 {
  58786. /** defines the current mouse button index */
  58787. buttonIndex: number;
  58788. /**
  58789. * Creates a new Vector3WithInfo
  58790. * @param source defines the vector3 data to transport
  58791. * @param buttonIndex defines the current mouse button index
  58792. */
  58793. constructor(source: BABYLON.Vector3,
  58794. /** defines the current mouse button index */
  58795. buttonIndex?: number);
  58796. }
  58797. }
  58798. declare module BABYLON.GUI {
  58799. /**
  58800. * Class used as base class for controls
  58801. */
  58802. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  58803. /** Defines the control name */
  58804. name?: string | undefined;
  58805. /** @hidden */ host: GUI3DManager;
  58806. private _node;
  58807. private _downCount;
  58808. private _enterCount;
  58809. private _downPointerIds;
  58810. private _isVisible;
  58811. /** Gets or sets the control position in world space */
  58812. position: BABYLON.Vector3;
  58813. /** Gets or sets the control scaling in world space */
  58814. scaling: BABYLON.Vector3;
  58815. /** Callback used to start pointer enter animation */
  58816. pointerEnterAnimation: () => void;
  58817. /** Callback used to start pointer out animation */
  58818. pointerOutAnimation: () => void;
  58819. /** Callback used to start pointer down animation */
  58820. pointerDownAnimation: () => void;
  58821. /** Callback used to start pointer up animation */
  58822. pointerUpAnimation: () => void;
  58823. /**
  58824. * An event triggered when the pointer move over the control
  58825. */
  58826. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  58827. /**
  58828. * An event triggered when the pointer move out of the control
  58829. */
  58830. onPointerOutObservable: BABYLON.Observable<Control3D>;
  58831. /**
  58832. * An event triggered when the pointer taps the control
  58833. */
  58834. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  58835. /**
  58836. * An event triggered when pointer is up
  58837. */
  58838. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  58839. /**
  58840. * An event triggered when a control is clicked on (with a mouse)
  58841. */
  58842. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  58843. /**
  58844. * An event triggered when pointer enters the control
  58845. */
  58846. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  58847. /**
  58848. * Gets or sets the parent container
  58849. */
  58850. parent: BABYLON.Nullable<Container3D>;
  58851. private _behaviors;
  58852. /**
  58853. * Gets the list of attached behaviors
  58854. * @see http://doc.babylonjs.com/features/behaviour
  58855. */
  58856. readonly behaviors: BABYLON.Behavior<Control3D>[];
  58857. /**
  58858. * Attach a behavior to the control
  58859. * @see http://doc.babylonjs.com/features/behaviour
  58860. * @param behavior defines the behavior to attach
  58861. * @returns the current control
  58862. */
  58863. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  58864. /**
  58865. * Remove an attached behavior
  58866. * @see http://doc.babylonjs.com/features/behaviour
  58867. * @param behavior defines the behavior to attach
  58868. * @returns the current control
  58869. */
  58870. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  58871. /**
  58872. * Gets an attached behavior by name
  58873. * @param name defines the name of the behavior to look for
  58874. * @see http://doc.babylonjs.com/features/behaviour
  58875. * @returns null if behavior was not found else the requested behavior
  58876. */
  58877. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  58878. /** Gets or sets a boolean indicating if the control is visible */
  58879. isVisible: boolean;
  58880. /**
  58881. * Creates a new control
  58882. * @param name defines the control name
  58883. */
  58884. constructor(
  58885. /** Defines the control name */
  58886. name?: string | undefined);
  58887. /**
  58888. * Gets a string representing the class name
  58889. */
  58890. readonly typeName: string;
  58891. /**
  58892. * Get the current class name of the control.
  58893. * @returns current class name
  58894. */
  58895. getClassName(): string;
  58896. protected _getTypeName(): string;
  58897. /**
  58898. * Gets the transform node used by this control
  58899. */
  58900. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  58901. /**
  58902. * Gets the mesh used to render this control
  58903. */
  58904. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  58905. /**
  58906. * Link the control as child of the given node
  58907. * @param node defines the node to link to. Use null to unlink the control
  58908. * @returns the current control
  58909. */
  58910. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  58911. /** @hidden **/ prepareNode(scene: BABYLON.Scene): void;
  58912. /**
  58913. * Node creation.
  58914. * Can be overriden by children
  58915. * @param scene defines the scene where the node must be attached
  58916. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  58917. */
  58918. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  58919. /**
  58920. * Affect a material to the given mesh
  58921. * @param mesh defines the mesh which will represent the control
  58922. */
  58923. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  58924. /** @hidden */ onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  58925. /** @hidden */ onPointerEnter(target: Control3D): boolean;
  58926. /** @hidden */ onPointerOut(target: Control3D): void;
  58927. /** @hidden */ onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  58928. /** @hidden */ onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  58929. /** @hidden */
  58930. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  58931. /** @hidden */ processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  58932. /** @hidden */ disposeNode(): void;
  58933. /**
  58934. * Releases all associated resources
  58935. */
  58936. dispose(): void;
  58937. }
  58938. }
  58939. declare module BABYLON.GUI {
  58940. /**
  58941. * Class used as a root to all buttons
  58942. */
  58943. export class AbstractButton3D extends Control3D {
  58944. /**
  58945. * Creates a new button
  58946. * @param name defines the control name
  58947. */
  58948. constructor(name?: string);
  58949. protected _getTypeName(): string;
  58950. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  58951. }
  58952. }
  58953. declare module BABYLON.GUI {
  58954. /**
  58955. * Class used to create a button in 3D
  58956. */
  58957. export class Button3D extends AbstractButton3D {
  58958. /** @hidden */
  58959. protected _currentMaterial: BABYLON.Material;
  58960. private _facadeTexture;
  58961. private _content;
  58962. private _contentResolution;
  58963. private _contentScaleRatio;
  58964. /**
  58965. * Gets or sets the texture resolution used to render content (512 by default)
  58966. */
  58967. contentResolution: BABYLON.int;
  58968. /**
  58969. * Gets or sets the texture scale ratio used to render content (2 by default)
  58970. */
  58971. contentScaleRatio: number;
  58972. protected _disposeFacadeTexture(): void;
  58973. protected _resetContent(): void;
  58974. /**
  58975. * Creates a new button
  58976. * @param name defines the control name
  58977. */
  58978. constructor(name?: string);
  58979. /**
  58980. * Gets or sets the GUI 2D content used to display the button's facade
  58981. */
  58982. content: Control;
  58983. /**
  58984. * Apply the facade texture (created from the content property).
  58985. * This function can be overloaded by child classes
  58986. * @param facadeTexture defines the AdvancedDynamicTexture to use
  58987. */
  58988. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  58989. protected _getTypeName(): string;
  58990. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  58991. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  58992. /**
  58993. * Releases all associated resources
  58994. */
  58995. dispose(): void;
  58996. }
  58997. }
  58998. declare module BABYLON.GUI {
  58999. /**
  59000. * Abstract class used to create a container panel deployed on the surface of a volume
  59001. */
  59002. export abstract class VolumeBasedPanel extends Container3D {
  59003. private _columns;
  59004. private _rows;
  59005. private _rowThenColum;
  59006. private _orientation;
  59007. protected _cellWidth: number;
  59008. protected _cellHeight: number;
  59009. /**
  59010. * Gets or sets the distance between elements
  59011. */
  59012. margin: number;
  59013. /**
  59014. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  59015. * | Value | Type | Description |
  59016. * | ----- | ----------------------------------- | ----------- |
  59017. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  59018. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  59019. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  59020. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  59021. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  59022. */
  59023. orientation: number;
  59024. /**
  59025. * Gets or sets the number of columns requested (10 by default).
  59026. * The panel will automatically compute the number of rows based on number of child controls.
  59027. */
  59028. columns: BABYLON.int;
  59029. /**
  59030. * Gets or sets a the number of rows requested.
  59031. * The panel will automatically compute the number of columns based on number of child controls.
  59032. */
  59033. rows: BABYLON.int;
  59034. /**
  59035. * Creates new VolumeBasedPanel
  59036. */
  59037. constructor();
  59038. protected _arrangeChildren(): void;
  59039. /** Child classes must implement this function to provide correct control positioning */
  59040. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59041. /** Child classes can implement this function to provide additional processing */
  59042. protected _finalProcessing(): void;
  59043. }
  59044. }
  59045. declare module BABYLON.GUI {
  59046. /**
  59047. * Class used to create a container panel deployed on the surface of a cylinder
  59048. */
  59049. export class CylinderPanel extends VolumeBasedPanel {
  59050. private _radius;
  59051. /**
  59052. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  59053. */
  59054. radius: BABYLON.float;
  59055. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59056. private _cylindricalMapping;
  59057. }
  59058. }
  59059. declare module BABYLON.GUI {
  59060. /** @hidden */
  59061. export var fluentVertexShader: {
  59062. name: string;
  59063. shader: string;
  59064. };
  59065. }
  59066. declare module BABYLON.GUI {
  59067. /** @hidden */
  59068. export var fluentPixelShader: {
  59069. name: string;
  59070. shader: string;
  59071. };
  59072. }
  59073. declare module BABYLON.GUI {
  59074. /** @hidden */
  59075. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  59076. INNERGLOW: boolean;
  59077. BORDER: boolean;
  59078. HOVERLIGHT: boolean;
  59079. TEXTURE: boolean;
  59080. constructor();
  59081. }
  59082. /**
  59083. * Class used to render controls with fluent desgin
  59084. */
  59085. export class FluentMaterial extends BABYLON.PushMaterial {
  59086. /**
  59087. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  59088. */
  59089. innerGlowColorIntensity: number;
  59090. /**
  59091. * Gets or sets the inner glow color (white by default)
  59092. */
  59093. innerGlowColor: BABYLON.Color3;
  59094. /**
  59095. * Gets or sets alpha value (default is 1.0)
  59096. */
  59097. alpha: number;
  59098. /**
  59099. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  59100. */
  59101. albedoColor: BABYLON.Color3;
  59102. /**
  59103. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  59104. */
  59105. renderBorders: boolean;
  59106. /**
  59107. * Gets or sets border width (default is 0.5)
  59108. */
  59109. borderWidth: number;
  59110. /**
  59111. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  59112. */
  59113. edgeSmoothingValue: number;
  59114. /**
  59115. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  59116. */
  59117. borderMinValue: number;
  59118. /**
  59119. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  59120. */
  59121. renderHoverLight: boolean;
  59122. /**
  59123. * Gets or sets the radius used to render the hover light (default is 1.0)
  59124. */
  59125. hoverRadius: number;
  59126. /**
  59127. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  59128. */
  59129. hoverColor: BABYLON.Color4;
  59130. /**
  59131. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  59132. */
  59133. hoverPosition: BABYLON.Vector3;
  59134. private _albedoTexture;
  59135. /** Gets or sets the texture to use for albedo color */
  59136. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  59137. /**
  59138. * Creates a new Fluent material
  59139. * @param name defines the name of the material
  59140. * @param scene defines the hosting scene
  59141. */
  59142. constructor(name: string, scene: BABYLON.Scene);
  59143. needAlphaBlending(): boolean;
  59144. needAlphaTesting(): boolean;
  59145. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  59146. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  59147. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  59148. getActiveTextures(): BABYLON.BaseTexture[];
  59149. hasTexture(texture: BABYLON.BaseTexture): boolean;
  59150. dispose(forceDisposeEffect?: boolean): void;
  59151. clone(name: string): FluentMaterial;
  59152. serialize(): any;
  59153. getClassName(): string;
  59154. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  59155. }
  59156. }
  59157. declare module BABYLON.GUI {
  59158. /**
  59159. * Class used to create a holographic button in 3D
  59160. */
  59161. export class HolographicButton extends Button3D {
  59162. private _backPlate;
  59163. private _textPlate;
  59164. private _frontPlate;
  59165. private _text;
  59166. private _imageUrl;
  59167. private _shareMaterials;
  59168. private _frontMaterial;
  59169. private _backMaterial;
  59170. private _plateMaterial;
  59171. private _pickedPointObserver;
  59172. private _tooltipFade;
  59173. private _tooltipTextBlock;
  59174. private _tooltipTexture;
  59175. private _tooltipMesh;
  59176. private _tooltipHoverObserver;
  59177. private _tooltipOutObserver;
  59178. private _disposeTooltip;
  59179. /**
  59180. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  59181. */
  59182. tooltipText: BABYLON.Nullable<string>;
  59183. /**
  59184. * Gets or sets text for the button
  59185. */
  59186. text: string;
  59187. /**
  59188. * Gets or sets the image url for the button
  59189. */
  59190. imageUrl: string;
  59191. /**
  59192. * Gets the back material used by this button
  59193. */
  59194. readonly backMaterial: FluentMaterial;
  59195. /**
  59196. * Gets the front material used by this button
  59197. */
  59198. readonly frontMaterial: FluentMaterial;
  59199. /**
  59200. * Gets the plate material used by this button
  59201. */
  59202. readonly plateMaterial: BABYLON.StandardMaterial;
  59203. /**
  59204. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  59205. */
  59206. readonly shareMaterials: boolean;
  59207. /**
  59208. * Creates a new button
  59209. * @param name defines the control name
  59210. */
  59211. constructor(name?: string, shareMaterials?: boolean);
  59212. protected _getTypeName(): string;
  59213. private _rebuildContent;
  59214. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59215. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  59216. private _createBackMaterial;
  59217. private _createFrontMaterial;
  59218. private _createPlateMaterial;
  59219. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  59220. /**
  59221. * Releases all associated resources
  59222. */
  59223. dispose(): void;
  59224. }
  59225. }
  59226. declare module BABYLON.GUI {
  59227. /**
  59228. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  59229. */
  59230. export class MeshButton3D extends Button3D {
  59231. /** @hidden */
  59232. protected _currentMesh: BABYLON.Mesh;
  59233. /**
  59234. * Creates a new 3D button based on a mesh
  59235. * @param mesh mesh to become a 3D button
  59236. * @param name defines the control name
  59237. */
  59238. constructor(mesh: BABYLON.Mesh, name?: string);
  59239. protected _getTypeName(): string;
  59240. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59241. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59242. }
  59243. }
  59244. declare module BABYLON.GUI {
  59245. /**
  59246. * Class used to create a container panel deployed on the surface of a plane
  59247. */
  59248. export class PlanePanel extends VolumeBasedPanel {
  59249. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59250. }
  59251. }
  59252. declare module BABYLON.GUI {
  59253. /**
  59254. * Class used to create a container panel where items get randomized planar mapping
  59255. */
  59256. export class ScatterPanel extends VolumeBasedPanel {
  59257. private _iteration;
  59258. /**
  59259. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  59260. */
  59261. iteration: BABYLON.float;
  59262. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59263. private _scatterMapping;
  59264. protected _finalProcessing(): void;
  59265. }
  59266. }
  59267. declare module BABYLON.GUI {
  59268. /**
  59269. * Class used to create a container panel deployed on the surface of a sphere
  59270. */
  59271. export class SpherePanel extends VolumeBasedPanel {
  59272. private _radius;
  59273. /**
  59274. * Gets or sets the radius of the sphere where to project controls (5 by default)
  59275. */
  59276. radius: BABYLON.float;
  59277. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59278. private _sphericalMapping;
  59279. }
  59280. }
  59281. declare module BABYLON.GUI {
  59282. /**
  59283. * Class used to create a stack panel in 3D on XY plane
  59284. */
  59285. export class StackPanel3D extends Container3D {
  59286. private _isVertical;
  59287. /**
  59288. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  59289. */
  59290. isVertical: boolean;
  59291. /**
  59292. * Gets or sets the distance between elements
  59293. */
  59294. margin: number;
  59295. /**
  59296. * Creates new StackPanel
  59297. * @param isVertical
  59298. */
  59299. constructor(isVertical?: boolean);
  59300. protected _arrangeChildren(): void;
  59301. }
  59302. }
  59303. declare module BABYLON {
  59304. /**
  59305. * Mode that determines the coordinate system to use.
  59306. */
  59307. export enum GLTFLoaderCoordinateSystemMode {
  59308. /**
  59309. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  59310. */
  59311. AUTO = 0,
  59312. /**
  59313. * Sets the useRightHandedSystem flag on the scene.
  59314. */
  59315. FORCE_RIGHT_HANDED = 1
  59316. }
  59317. /**
  59318. * Mode that determines what animations will start.
  59319. */
  59320. export enum GLTFLoaderAnimationStartMode {
  59321. /**
  59322. * No animation will start.
  59323. */
  59324. NONE = 0,
  59325. /**
  59326. * The first animation will start.
  59327. */
  59328. FIRST = 1,
  59329. /**
  59330. * All animations will start.
  59331. */
  59332. ALL = 2
  59333. }
  59334. /**
  59335. * Interface that contains the data for the glTF asset.
  59336. */
  59337. export interface IGLTFLoaderData {
  59338. /**
  59339. * Object that represents the glTF JSON.
  59340. */
  59341. json: Object;
  59342. /**
  59343. * The BIN chunk of a binary glTF.
  59344. */
  59345. bin: Nullable<ArrayBufferView>;
  59346. }
  59347. /**
  59348. * Interface for extending the loader.
  59349. */
  59350. export interface IGLTFLoaderExtension {
  59351. /**
  59352. * The name of this extension.
  59353. */
  59354. readonly name: string;
  59355. /**
  59356. * Defines whether this extension is enabled.
  59357. */
  59358. enabled: boolean;
  59359. }
  59360. /**
  59361. * Loader state.
  59362. */
  59363. export enum GLTFLoaderState {
  59364. /**
  59365. * The asset is loading.
  59366. */
  59367. LOADING = 0,
  59368. /**
  59369. * The asset is ready for rendering.
  59370. */
  59371. READY = 1,
  59372. /**
  59373. * The asset is completely loaded.
  59374. */
  59375. COMPLETE = 2
  59376. }
  59377. /** @hidden */
  59378. export interface IGLTFLoader extends IDisposable {
  59379. readonly state: Nullable<GLTFLoaderState>;
  59380. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  59381. meshes: AbstractMesh[];
  59382. particleSystems: IParticleSystem[];
  59383. skeletons: Skeleton[];
  59384. animationGroups: AnimationGroup[];
  59385. }>;
  59386. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  59387. }
  59388. /**
  59389. * File loader for loading glTF files into a scene.
  59390. */
  59391. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  59392. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  59393. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  59394. /**
  59395. * Raised when the asset has been parsed
  59396. */
  59397. onParsedObservable: Observable<IGLTFLoaderData>;
  59398. private _onParsedObserver;
  59399. /**
  59400. * Raised when the asset has been parsed
  59401. */
  59402. onParsed: (loaderData: IGLTFLoaderData) => void;
  59403. /**
  59404. * Set this property to false to disable incremental loading which delays the loader from calling the success callback until after loading the meshes and shaders.
  59405. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  59406. * Defaults to true.
  59407. * @hidden
  59408. */
  59409. static IncrementalLoading: boolean;
  59410. /**
  59411. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  59412. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  59413. * @hidden
  59414. */
  59415. static HomogeneousCoordinates: boolean;
  59416. /**
  59417. * The coordinate system mode. Defaults to AUTO.
  59418. */
  59419. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  59420. /**
  59421. * The animation start mode. Defaults to FIRST.
  59422. */
  59423. animationStartMode: GLTFLoaderAnimationStartMode;
  59424. /**
  59425. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  59426. */
  59427. compileMaterials: boolean;
  59428. /**
  59429. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  59430. */
  59431. useClipPlane: boolean;
  59432. /**
  59433. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  59434. */
  59435. compileShadowGenerators: boolean;
  59436. /**
  59437. * Defines if the Alpha blended materials are only applied as coverage.
  59438. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  59439. * If true, no extra effects are applied to transparent pixels.
  59440. */
  59441. transparencyAsCoverage: boolean;
  59442. /**
  59443. * Function called before loading a url referenced by the asset.
  59444. */
  59445. preprocessUrlAsync: (url: string) => Promise<string>;
  59446. /**
  59447. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  59448. */
  59449. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  59450. private _onMeshLoadedObserver;
  59451. /**
  59452. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  59453. */
  59454. onMeshLoaded: (mesh: AbstractMesh) => void;
  59455. /**
  59456. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  59457. */
  59458. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  59459. private _onTextureLoadedObserver;
  59460. /**
  59461. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  59462. */
  59463. onTextureLoaded: (texture: BaseTexture) => void;
  59464. /**
  59465. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  59466. */
  59467. readonly onMaterialLoadedObservable: Observable<Material>;
  59468. private _onMaterialLoadedObserver;
  59469. /**
  59470. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  59471. */
  59472. onMaterialLoaded: (material: Material) => void;
  59473. /**
  59474. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  59475. */
  59476. readonly onCameraLoadedObservable: Observable<Camera>;
  59477. private _onCameraLoadedObserver;
  59478. /**
  59479. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  59480. */
  59481. onCameraLoaded: (camera: Camera) => void;
  59482. /**
  59483. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  59484. * For assets with LODs, raised when all of the LODs are complete.
  59485. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  59486. */
  59487. readonly onCompleteObservable: Observable<void>;
  59488. private _onCompleteObserver;
  59489. /**
  59490. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  59491. * For assets with LODs, raised when all of the LODs are complete.
  59492. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  59493. */
  59494. onComplete: () => void;
  59495. /**
  59496. * Observable raised when an error occurs.
  59497. */
  59498. readonly onErrorObservable: Observable<any>;
  59499. private _onErrorObserver;
  59500. /**
  59501. * Callback raised when an error occurs.
  59502. */
  59503. onError: (reason: any) => void;
  59504. /**
  59505. * Observable raised after the loader is disposed.
  59506. */
  59507. readonly onDisposeObservable: Observable<void>;
  59508. private _onDisposeObserver;
  59509. /**
  59510. * Callback raised after the loader is disposed.
  59511. */
  59512. onDispose: () => void;
  59513. /**
  59514. * Observable raised after a loader extension is created.
  59515. * Set additional options for a loader extension in this event.
  59516. */
  59517. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  59518. private _onExtensionLoadedObserver;
  59519. /**
  59520. * Callback raised after a loader extension is created.
  59521. */
  59522. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  59523. /**
  59524. * Defines if the loader logging is enabled.
  59525. */
  59526. loggingEnabled: boolean;
  59527. /**
  59528. * Defines if the loader should capture performance counters.
  59529. */
  59530. capturePerformanceCounters: boolean;
  59531. /**
  59532. * Defines if the loader should validate the asset.
  59533. */
  59534. validate: boolean;
  59535. /**
  59536. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  59537. */
  59538. readonly onValidatedObservable: Observable<IGLTFValidationResults>;
  59539. private _onValidatedObserver;
  59540. /**
  59541. * Callback raised after a loader extension is created.
  59542. */
  59543. onValidated: (results: IGLTFValidationResults) => void;
  59544. private _loader;
  59545. /**
  59546. * Name of the loader ("gltf")
  59547. */
  59548. name: string;
  59549. /**
  59550. * Supported file extensions of the loader (.gltf, .glb)
  59551. */
  59552. extensions: ISceneLoaderPluginExtensions;
  59553. /**
  59554. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  59555. */
  59556. dispose(): void;
  59557. /** @hidden */ clear(): void;
  59558. /**
  59559. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  59560. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  59561. * @param scene the scene the meshes should be added to
  59562. * @param data the glTF data to load
  59563. * @param rootUrl root url to load from
  59564. * @param onProgress event that fires when loading progress has occured
  59565. * @param fileName Defines the name of the file to load
  59566. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  59567. */
  59568. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  59569. meshes: AbstractMesh[];
  59570. particleSystems: IParticleSystem[];
  59571. skeletons: Skeleton[];
  59572. animationGroups: AnimationGroup[];
  59573. }>;
  59574. /**
  59575. * Imports all objects from the loaded glTF data and adds them to the scene
  59576. * @param scene the scene the objects should be added to
  59577. * @param data the glTF data to load
  59578. * @param rootUrl root url to load from
  59579. * @param onProgress event that fires when loading progress has occured
  59580. * @param fileName Defines the name of the file to load
  59581. * @returns a promise which completes when objects have been loaded to the scene
  59582. */
  59583. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  59584. /**
  59585. * Load into an asset container.
  59586. * @param scene The scene to load into
  59587. * @param data The data to import
  59588. * @param rootUrl The root url for scene and resources
  59589. * @param onProgress The callback when the load progresses
  59590. * @param fileName Defines the name of the file to load
  59591. * @returns The loaded asset container
  59592. */
  59593. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  59594. /**
  59595. * If the data string can be loaded directly.
  59596. * @param data string contianing the file data
  59597. * @returns if the data can be loaded directly
  59598. */
  59599. canDirectLoad(data: string): boolean;
  59600. /**
  59601. * Rewrites a url by combining a root url and response url.
  59602. */
  59603. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  59604. /**
  59605. * Instantiates a glTF file loader plugin.
  59606. * @returns the created plugin
  59607. */
  59608. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  59609. /**
  59610. * The loader state or null if the loader is not active.
  59611. */
  59612. readonly loaderState: Nullable<GLTFLoaderState>;
  59613. /**
  59614. * Returns a promise that resolves when the asset is completely loaded.
  59615. * @returns a promise that resolves when the asset is completely loaded.
  59616. */
  59617. whenCompleteAsync(): Promise<void>;
  59618. private _parseAsync;
  59619. private _validateAsync;
  59620. private _getLoader;
  59621. private _unpackBinary;
  59622. private _unpackBinaryV1;
  59623. private _unpackBinaryV2;
  59624. private static _parseVersion;
  59625. private static _compareVersion;
  59626. private static _decodeBufferToText;
  59627. private static readonly _logSpaces;
  59628. private _logIndentLevel;
  59629. private _loggingEnabled;
  59630. /** @hidden */ log: (message: string) => void;
  59631. /** @hidden */ logOpen(message: string): void;
  59632. /** @hidden */ logClose(): void;
  59633. private _logEnabled;
  59634. private _logDisabled;
  59635. private _capturePerformanceCounters;
  59636. /** @hidden */ startPerformanceCounter: (counterName: string) => void;
  59637. /** @hidden */ endPerformanceCounter: (counterName: string) => void;
  59638. private _startPerformanceCounterEnabled;
  59639. private _startPerformanceCounterDisabled;
  59640. private _endPerformanceCounterEnabled;
  59641. private _endPerformanceCounterDisabled;
  59642. }
  59643. }
  59644. declare module BABYLON.GLTF1 {
  59645. /**
  59646. * Enums
  59647. * @hidden
  59648. */
  59649. export enum EComponentType {
  59650. BYTE = 5120,
  59651. UNSIGNED_BYTE = 5121,
  59652. SHORT = 5122,
  59653. UNSIGNED_SHORT = 5123,
  59654. FLOAT = 5126
  59655. }
  59656. /** @hidden */
  59657. export enum EShaderType {
  59658. FRAGMENT = 35632,
  59659. VERTEX = 35633
  59660. }
  59661. /** @hidden */
  59662. export enum EParameterType {
  59663. BYTE = 5120,
  59664. UNSIGNED_BYTE = 5121,
  59665. SHORT = 5122,
  59666. UNSIGNED_SHORT = 5123,
  59667. INT = 5124,
  59668. UNSIGNED_INT = 5125,
  59669. FLOAT = 5126,
  59670. FLOAT_VEC2 = 35664,
  59671. FLOAT_VEC3 = 35665,
  59672. FLOAT_VEC4 = 35666,
  59673. INT_VEC2 = 35667,
  59674. INT_VEC3 = 35668,
  59675. INT_VEC4 = 35669,
  59676. BOOL = 35670,
  59677. BOOL_VEC2 = 35671,
  59678. BOOL_VEC3 = 35672,
  59679. BOOL_VEC4 = 35673,
  59680. FLOAT_MAT2 = 35674,
  59681. FLOAT_MAT3 = 35675,
  59682. FLOAT_MAT4 = 35676,
  59683. SAMPLER_2D = 35678
  59684. }
  59685. /** @hidden */
  59686. export enum ETextureWrapMode {
  59687. CLAMP_TO_EDGE = 33071,
  59688. MIRRORED_REPEAT = 33648,
  59689. REPEAT = 10497
  59690. }
  59691. /** @hidden */
  59692. export enum ETextureFilterType {
  59693. NEAREST = 9728,
  59694. LINEAR = 9728,
  59695. NEAREST_MIPMAP_NEAREST = 9984,
  59696. LINEAR_MIPMAP_NEAREST = 9985,
  59697. NEAREST_MIPMAP_LINEAR = 9986,
  59698. LINEAR_MIPMAP_LINEAR = 9987
  59699. }
  59700. /** @hidden */
  59701. export enum ETextureFormat {
  59702. ALPHA = 6406,
  59703. RGB = 6407,
  59704. RGBA = 6408,
  59705. LUMINANCE = 6409,
  59706. LUMINANCE_ALPHA = 6410
  59707. }
  59708. /** @hidden */
  59709. export enum ECullingType {
  59710. FRONT = 1028,
  59711. BACK = 1029,
  59712. FRONT_AND_BACK = 1032
  59713. }
  59714. /** @hidden */
  59715. export enum EBlendingFunction {
  59716. ZERO = 0,
  59717. ONE = 1,
  59718. SRC_COLOR = 768,
  59719. ONE_MINUS_SRC_COLOR = 769,
  59720. DST_COLOR = 774,
  59721. ONE_MINUS_DST_COLOR = 775,
  59722. SRC_ALPHA = 770,
  59723. ONE_MINUS_SRC_ALPHA = 771,
  59724. DST_ALPHA = 772,
  59725. ONE_MINUS_DST_ALPHA = 773,
  59726. CONSTANT_COLOR = 32769,
  59727. ONE_MINUS_CONSTANT_COLOR = 32770,
  59728. CONSTANT_ALPHA = 32771,
  59729. ONE_MINUS_CONSTANT_ALPHA = 32772,
  59730. SRC_ALPHA_SATURATE = 776
  59731. }
  59732. /** @hidden */
  59733. export interface IGLTFProperty {
  59734. extensions?: {
  59735. [key: string]: any;
  59736. };
  59737. extras?: Object;
  59738. }
  59739. /** @hidden */
  59740. export interface IGLTFChildRootProperty extends IGLTFProperty {
  59741. name?: string;
  59742. }
  59743. /** @hidden */
  59744. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  59745. bufferView: string;
  59746. byteOffset: number;
  59747. byteStride: number;
  59748. count: number;
  59749. type: string;
  59750. componentType: EComponentType;
  59751. max?: number[];
  59752. min?: number[];
  59753. name?: string;
  59754. }
  59755. /** @hidden */
  59756. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  59757. buffer: string;
  59758. byteOffset: number;
  59759. byteLength: number;
  59760. byteStride: number;
  59761. target?: number;
  59762. }
  59763. /** @hidden */
  59764. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  59765. uri: string;
  59766. byteLength?: number;
  59767. type?: string;
  59768. }
  59769. /** @hidden */
  59770. export interface IGLTFShader extends IGLTFChildRootProperty {
  59771. uri: string;
  59772. type: EShaderType;
  59773. }
  59774. /** @hidden */
  59775. export interface IGLTFProgram extends IGLTFChildRootProperty {
  59776. attributes: string[];
  59777. fragmentShader: string;
  59778. vertexShader: string;
  59779. }
  59780. /** @hidden */
  59781. export interface IGLTFTechniqueParameter {
  59782. type: number;
  59783. count?: number;
  59784. semantic?: string;
  59785. node?: string;
  59786. value?: number | boolean | string | Array<any>;
  59787. source?: string;
  59788. babylonValue?: any;
  59789. }
  59790. /** @hidden */
  59791. export interface IGLTFTechniqueCommonProfile {
  59792. lightingModel: string;
  59793. texcoordBindings: Object;
  59794. parameters?: Array<any>;
  59795. }
  59796. /** @hidden */
  59797. export interface IGLTFTechniqueStatesFunctions {
  59798. blendColor?: number[];
  59799. blendEquationSeparate?: number[];
  59800. blendFuncSeparate?: number[];
  59801. colorMask: boolean[];
  59802. cullFace: number[];
  59803. }
  59804. /** @hidden */
  59805. export interface IGLTFTechniqueStates {
  59806. enable: number[];
  59807. functions: IGLTFTechniqueStatesFunctions;
  59808. }
  59809. /** @hidden */
  59810. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  59811. parameters: {
  59812. [key: string]: IGLTFTechniqueParameter;
  59813. };
  59814. program: string;
  59815. attributes: {
  59816. [key: string]: string;
  59817. };
  59818. uniforms: {
  59819. [key: string]: string;
  59820. };
  59821. states: IGLTFTechniqueStates;
  59822. }
  59823. /** @hidden */
  59824. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  59825. technique?: string;
  59826. values: string[];
  59827. }
  59828. /** @hidden */
  59829. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  59830. attributes: {
  59831. [key: string]: string;
  59832. };
  59833. indices: string;
  59834. material: string;
  59835. mode?: number;
  59836. }
  59837. /** @hidden */
  59838. export interface IGLTFMesh extends IGLTFChildRootProperty {
  59839. primitives: IGLTFMeshPrimitive[];
  59840. }
  59841. /** @hidden */
  59842. export interface IGLTFImage extends IGLTFChildRootProperty {
  59843. uri: string;
  59844. }
  59845. /** @hidden */
  59846. export interface IGLTFSampler extends IGLTFChildRootProperty {
  59847. magFilter?: number;
  59848. minFilter?: number;
  59849. wrapS?: number;
  59850. wrapT?: number;
  59851. }
  59852. /** @hidden */
  59853. export interface IGLTFTexture extends IGLTFChildRootProperty {
  59854. sampler: string;
  59855. source: string;
  59856. format?: ETextureFormat;
  59857. internalFormat?: ETextureFormat;
  59858. target?: number;
  59859. type?: number;
  59860. babylonTexture?: Texture;
  59861. }
  59862. /** @hidden */
  59863. export interface IGLTFAmbienLight {
  59864. color?: number[];
  59865. }
  59866. /** @hidden */
  59867. export interface IGLTFDirectionalLight {
  59868. color?: number[];
  59869. }
  59870. /** @hidden */
  59871. export interface IGLTFPointLight {
  59872. color?: number[];
  59873. constantAttenuation?: number;
  59874. linearAttenuation?: number;
  59875. quadraticAttenuation?: number;
  59876. }
  59877. /** @hidden */
  59878. export interface IGLTFSpotLight {
  59879. color?: number[];
  59880. constantAttenuation?: number;
  59881. fallOfAngle?: number;
  59882. fallOffExponent?: number;
  59883. linearAttenuation?: number;
  59884. quadraticAttenuation?: number;
  59885. }
  59886. /** @hidden */
  59887. export interface IGLTFLight extends IGLTFChildRootProperty {
  59888. type: string;
  59889. }
  59890. /** @hidden */
  59891. export interface IGLTFCameraOrthographic {
  59892. xmag: number;
  59893. ymag: number;
  59894. zfar: number;
  59895. znear: number;
  59896. }
  59897. /** @hidden */
  59898. export interface IGLTFCameraPerspective {
  59899. aspectRatio: number;
  59900. yfov: number;
  59901. zfar: number;
  59902. znear: number;
  59903. }
  59904. /** @hidden */
  59905. export interface IGLTFCamera extends IGLTFChildRootProperty {
  59906. type: string;
  59907. }
  59908. /** @hidden */
  59909. export interface IGLTFAnimationChannelTarget {
  59910. id: string;
  59911. path: string;
  59912. }
  59913. /** @hidden */
  59914. export interface IGLTFAnimationChannel {
  59915. sampler: string;
  59916. target: IGLTFAnimationChannelTarget;
  59917. }
  59918. /** @hidden */
  59919. export interface IGLTFAnimationSampler {
  59920. input: string;
  59921. output: string;
  59922. interpolation?: string;
  59923. }
  59924. /** @hidden */
  59925. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  59926. channels?: IGLTFAnimationChannel[];
  59927. parameters?: {
  59928. [key: string]: string;
  59929. };
  59930. samplers?: {
  59931. [key: string]: IGLTFAnimationSampler;
  59932. };
  59933. }
  59934. /** @hidden */
  59935. export interface IGLTFNodeInstanceSkin {
  59936. skeletons: string[];
  59937. skin: string;
  59938. meshes: string[];
  59939. }
  59940. /** @hidden */
  59941. export interface IGLTFSkins extends IGLTFChildRootProperty {
  59942. bindShapeMatrix: number[];
  59943. inverseBindMatrices: string;
  59944. jointNames: string[];
  59945. babylonSkeleton?: Skeleton;
  59946. }
  59947. /** @hidden */
  59948. export interface IGLTFNode extends IGLTFChildRootProperty {
  59949. camera?: string;
  59950. children: string[];
  59951. skin?: string;
  59952. jointName?: string;
  59953. light?: string;
  59954. matrix: number[];
  59955. mesh?: string;
  59956. meshes?: string[];
  59957. rotation?: number[];
  59958. scale?: number[];
  59959. translation?: number[];
  59960. babylonNode?: Node;
  59961. }
  59962. /** @hidden */
  59963. export interface IGLTFScene extends IGLTFChildRootProperty {
  59964. nodes: string[];
  59965. }
  59966. /** @hidden */
  59967. export interface IGLTFRuntime {
  59968. extensions: {
  59969. [key: string]: any;
  59970. };
  59971. accessors: {
  59972. [key: string]: IGLTFAccessor;
  59973. };
  59974. buffers: {
  59975. [key: string]: IGLTFBuffer;
  59976. };
  59977. bufferViews: {
  59978. [key: string]: IGLTFBufferView;
  59979. };
  59980. meshes: {
  59981. [key: string]: IGLTFMesh;
  59982. };
  59983. lights: {
  59984. [key: string]: IGLTFLight;
  59985. };
  59986. cameras: {
  59987. [key: string]: IGLTFCamera;
  59988. };
  59989. nodes: {
  59990. [key: string]: IGLTFNode;
  59991. };
  59992. images: {
  59993. [key: string]: IGLTFImage;
  59994. };
  59995. textures: {
  59996. [key: string]: IGLTFTexture;
  59997. };
  59998. shaders: {
  59999. [key: string]: IGLTFShader;
  60000. };
  60001. programs: {
  60002. [key: string]: IGLTFProgram;
  60003. };
  60004. samplers: {
  60005. [key: string]: IGLTFSampler;
  60006. };
  60007. techniques: {
  60008. [key: string]: IGLTFTechnique;
  60009. };
  60010. materials: {
  60011. [key: string]: IGLTFMaterial;
  60012. };
  60013. animations: {
  60014. [key: string]: IGLTFAnimation;
  60015. };
  60016. skins: {
  60017. [key: string]: IGLTFSkins;
  60018. };
  60019. currentScene?: Object;
  60020. scenes: {
  60021. [key: string]: IGLTFScene;
  60022. };
  60023. extensionsUsed: string[];
  60024. extensionsRequired?: string[];
  60025. buffersCount: number;
  60026. shaderscount: number;
  60027. scene: Scene;
  60028. rootUrl: string;
  60029. loadedBufferCount: number;
  60030. loadedBufferViews: {
  60031. [name: string]: ArrayBufferView;
  60032. };
  60033. loadedShaderCount: number;
  60034. importOnlyMeshes: boolean;
  60035. importMeshesNames?: string[];
  60036. dummyNodes: Node[];
  60037. }
  60038. /** @hidden */
  60039. export interface INodeToRoot {
  60040. bone: Bone;
  60041. node: IGLTFNode;
  60042. id: string;
  60043. }
  60044. /** @hidden */
  60045. export interface IJointNode {
  60046. node: IGLTFNode;
  60047. id: string;
  60048. }
  60049. }
  60050. declare module BABYLON.GLTF1 {
  60051. /**
  60052. * Utils functions for GLTF
  60053. * @hidden
  60054. */
  60055. export class GLTFUtils {
  60056. /**
  60057. * Sets the given "parameter" matrix
  60058. * @param scene: the Scene object
  60059. * @param source: the source node where to pick the matrix
  60060. * @param parameter: the GLTF technique parameter
  60061. * @param uniformName: the name of the shader's uniform
  60062. * @param shaderMaterial: the shader material
  60063. */
  60064. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  60065. /**
  60066. * Sets the given "parameter" matrix
  60067. * @param shaderMaterial: the shader material
  60068. * @param uniform: the name of the shader's uniform
  60069. * @param value: the value of the uniform
  60070. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  60071. */
  60072. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  60073. /**
  60074. * Returns the wrap mode of the texture
  60075. * @param mode: the mode value
  60076. */
  60077. static GetWrapMode(mode: number): number;
  60078. /**
  60079. * Returns the byte stride giving an accessor
  60080. * @param accessor: the GLTF accessor objet
  60081. */
  60082. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  60083. /**
  60084. * Returns the texture filter mode giving a mode value
  60085. * @param mode: the filter mode value
  60086. */
  60087. static GetTextureFilterMode(mode: number): ETextureFilterType;
  60088. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  60089. /**
  60090. * Returns a buffer from its accessor
  60091. * @param gltfRuntime: the GLTF runtime
  60092. * @param accessor: the GLTF accessor
  60093. */
  60094. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  60095. /**
  60096. * Decodes a buffer view into a string
  60097. * @param view: the buffer view
  60098. */
  60099. static DecodeBufferToText(view: ArrayBufferView): string;
  60100. /**
  60101. * Returns the default material of gltf. Related to
  60102. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  60103. * @param scene: the Babylon.js scene
  60104. */
  60105. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  60106. private static _DefaultMaterial;
  60107. }
  60108. }
  60109. declare module BABYLON.GLTF1 {
  60110. /**
  60111. * Implementation of the base glTF spec
  60112. * @hidden
  60113. */
  60114. export class GLTFLoaderBase {
  60115. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  60116. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  60117. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  60118. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  60119. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  60120. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  60121. }
  60122. /**
  60123. * glTF V1 Loader
  60124. * @hidden
  60125. */
  60126. export class GLTFLoader implements IGLTFLoader {
  60127. static Extensions: {
  60128. [name: string]: GLTFLoaderExtension;
  60129. };
  60130. static RegisterExtension(extension: GLTFLoaderExtension): void;
  60131. state: Nullable<GLTFLoaderState>;
  60132. dispose(): void;
  60133. private _importMeshAsync;
  60134. /**
  60135. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  60136. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  60137. * @param scene the scene the meshes should be added to
  60138. * @param data gltf data containing information of the meshes in a loaded file
  60139. * @param rootUrl root url to load from
  60140. * @param onProgress event that fires when loading progress has occured
  60141. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  60142. */
  60143. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  60144. meshes: AbstractMesh[];
  60145. particleSystems: IParticleSystem[];
  60146. skeletons: Skeleton[];
  60147. animationGroups: AnimationGroup[];
  60148. }>;
  60149. private _loadAsync;
  60150. /**
  60151. * Imports all objects from a loaded gltf file and adds them to the scene
  60152. * @param scene the scene the objects should be added to
  60153. * @param data gltf data containing information of the meshes in a loaded file
  60154. * @param rootUrl root url to load from
  60155. * @param onProgress event that fires when loading progress has occured
  60156. * @returns a promise which completes when objects have been loaded to the scene
  60157. */
  60158. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  60159. private _loadShadersAsync;
  60160. private _loadBuffersAsync;
  60161. private _createNodes;
  60162. }
  60163. /** @hidden */
  60164. export abstract class GLTFLoaderExtension {
  60165. private _name;
  60166. constructor(name: string);
  60167. readonly name: string;
  60168. /**
  60169. * Defines an override for loading the runtime
  60170. * Return true to stop further extensions from loading the runtime
  60171. */
  60172. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  60173. /**
  60174. * Defines an onverride for creating gltf runtime
  60175. * Return true to stop further extensions from creating the runtime
  60176. */
  60177. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  60178. /**
  60179. * Defines an override for loading buffers
  60180. * Return true to stop further extensions from loading this buffer
  60181. */
  60182. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  60183. /**
  60184. * Defines an override for loading texture buffers
  60185. * Return true to stop further extensions from loading this texture data
  60186. */
  60187. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60188. /**
  60189. * Defines an override for creating textures
  60190. * Return true to stop further extensions from loading this texture
  60191. */
  60192. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  60193. /**
  60194. * Defines an override for loading shader strings
  60195. * Return true to stop further extensions from loading this shader data
  60196. */
  60197. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  60198. /**
  60199. * Defines an override for loading materials
  60200. * Return true to stop further extensions from loading this material
  60201. */
  60202. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  60203. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  60204. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  60205. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  60206. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  60207. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  60208. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  60209. private static LoadTextureBufferAsync;
  60210. private static CreateTextureAsync;
  60211. private static ApplyExtensions;
  60212. }
  60213. }
  60214. declare module BABYLON.GLTF1 {
  60215. /** @hidden */
  60216. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  60217. private _bin;
  60218. constructor();
  60219. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  60220. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60221. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60222. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  60223. }
  60224. }
  60225. declare module BABYLON.GLTF1 {
  60226. /** @hidden */
  60227. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  60228. constructor();
  60229. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  60230. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  60231. private _loadTexture;
  60232. }
  60233. }
  60234. declare module BABYLON.GLTF2.Loader {
  60235. /**
  60236. * Loader interface with an index field.
  60237. */
  60238. export interface IArrayItem {
  60239. /**
  60240. * The index of this item in the array.
  60241. */
  60242. index: number;
  60243. }
  60244. /**
  60245. * Loader interface with additional members.
  60246. */
  60247. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  60248. /** @hidden */ data?: Promise<ArrayBufferView>;
  60249. /** @hidden */ babylonVertexBuffer?: Promise<VertexBuffer>;
  60250. }
  60251. /**
  60252. * Loader interface with additional members.
  60253. */
  60254. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  60255. }
  60256. /** @hidden */
  60257. export interface _IAnimationSamplerData {
  60258. input: Float32Array;
  60259. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  60260. output: Float32Array;
  60261. }
  60262. /**
  60263. * Loader interface with additional members.
  60264. */
  60265. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  60266. /** @hidden */ data?: Promise<_IAnimationSamplerData>;
  60267. }
  60268. /**
  60269. * Loader interface with additional members.
  60270. */
  60271. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  60272. channels: IAnimationChannel[];
  60273. samplers: IAnimationSampler[];
  60274. /** @hidden */ babylonAnimationGroup?: AnimationGroup;
  60275. }
  60276. /**
  60277. * Loader interface with additional members.
  60278. */
  60279. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  60280. /** @hidden */ data?: Promise<ArrayBufferView>;
  60281. }
  60282. /**
  60283. * Loader interface with additional members.
  60284. */
  60285. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  60286. /** @hidden */ data?: Promise<ArrayBufferView>;
  60287. /** @hidden */ babylonBuffer?: Promise<Buffer>;
  60288. }
  60289. /**
  60290. * Loader interface with additional members.
  60291. */
  60292. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  60293. }
  60294. /**
  60295. * Loader interface with additional members.
  60296. */
  60297. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  60298. /** @hidden */ data?: Promise<ArrayBufferView>;
  60299. }
  60300. /**
  60301. * Loader interface with additional members.
  60302. */
  60303. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  60304. }
  60305. /**
  60306. * Loader interface with additional members.
  60307. */
  60308. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  60309. }
  60310. /**
  60311. * Loader interface with additional members.
  60312. */
  60313. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  60314. baseColorTexture?: ITextureInfo;
  60315. metallicRoughnessTexture?: ITextureInfo;
  60316. }
  60317. /**
  60318. * Loader interface with additional members.
  60319. */
  60320. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  60321. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  60322. normalTexture?: IMaterialNormalTextureInfo;
  60323. occlusionTexture?: IMaterialOcclusionTextureInfo;
  60324. emissiveTexture?: ITextureInfo;
  60325. /** @hidden */ data?: {
  60326. [babylonDrawMode: number]: {
  60327. babylonMaterial: Material;
  60328. babylonMeshes: AbstractMesh[];
  60329. promise: Promise<void>;
  60330. };
  60331. };
  60332. }
  60333. /**
  60334. * Loader interface with additional members.
  60335. */
  60336. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  60337. primitives: IMeshPrimitive[];
  60338. }
  60339. /**
  60340. * Loader interface with additional members.
  60341. */
  60342. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  60343. /** @hidden */ instanceData?: {
  60344. babylonSourceMesh: Mesh;
  60345. promise: Promise<any>;
  60346. };
  60347. }
  60348. /**
  60349. * Loader interface with additional members.
  60350. */
  60351. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  60352. /**
  60353. * The parent glTF node.
  60354. */
  60355. parent?: INode;
  60356. /** @hidden */ babylonTransformNode?: TransformNode;
  60357. /** @hidden */ primitiveBabylonMeshes?: AbstractMesh[];
  60358. /** @hidden */ babylonBones?: Bone[];
  60359. /** @hidden */ numMorphTargets?: number;
  60360. }
  60361. /** @hidden */
  60362. export interface _ISamplerData {
  60363. noMipMaps: boolean;
  60364. samplingMode: number;
  60365. wrapU: number;
  60366. wrapV: number;
  60367. }
  60368. /**
  60369. * Loader interface with additional members.
  60370. */
  60371. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  60372. /** @hidden */ data?: _ISamplerData;
  60373. }
  60374. /**
  60375. * Loader interface with additional members.
  60376. */
  60377. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  60378. }
  60379. /**
  60380. * Loader interface with additional members.
  60381. */
  60382. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  60383. /** @hidden */ data?: {
  60384. babylonSkeleton: Skeleton;
  60385. promise: Promise<void>;
  60386. };
  60387. }
  60388. /**
  60389. * Loader interface with additional members.
  60390. */
  60391. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  60392. }
  60393. /**
  60394. * Loader interface with additional members.
  60395. */
  60396. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  60397. }
  60398. /**
  60399. * Loader interface with additional members.
  60400. */
  60401. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  60402. accessors?: IAccessor[];
  60403. animations?: IAnimation[];
  60404. buffers?: IBuffer[];
  60405. bufferViews?: IBufferView[];
  60406. cameras?: ICamera[];
  60407. images?: IImage[];
  60408. materials?: IMaterial[];
  60409. meshes?: IMesh[];
  60410. nodes?: INode[];
  60411. samplers?: ISampler[];
  60412. scenes?: IScene[];
  60413. skins?: ISkin[];
  60414. textures?: ITexture[];
  60415. }
  60416. }
  60417. declare module BABYLON.GLTF2 {
  60418. /**
  60419. * Interface for a glTF loader extension.
  60420. */
  60421. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  60422. /**
  60423. * Called after the loader state changes to LOADING.
  60424. */
  60425. onLoading?(): void;
  60426. /**
  60427. * Called after the loader state changes to READY.
  60428. */
  60429. onReady?(): void;
  60430. /**
  60431. * Define this method to modify the default behavior when loading scenes.
  60432. * @param context The context when loading the asset
  60433. * @param scene The glTF scene property
  60434. * @returns A promise that resolves when the load is complete or null if not handled
  60435. */
  60436. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  60437. /**
  60438. * Define this method to modify the default behavior when loading nodes.
  60439. * @param context The context when loading the asset
  60440. * @param node The glTF node property
  60441. * @param assign A function called synchronously after parsing the glTF properties
  60442. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  60443. */
  60444. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  60445. /**
  60446. * Define this method to modify the default behavior when loading cameras.
  60447. * @param context The context when loading the asset
  60448. * @param camera The glTF camera property
  60449. * @param assign A function called synchronously after parsing the glTF properties
  60450. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  60451. */
  60452. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  60453. /**
  60454. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  60455. * @param context The context when loading the asset
  60456. * @param primitive The glTF mesh primitive property
  60457. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  60458. */ loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  60459. /**
  60460. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  60461. * @param context The context when loading the asset
  60462. * @param material The glTF material property
  60463. * @param assign A function called synchronously after parsing the glTF properties
  60464. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  60465. */ loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  60466. /**
  60467. * Define this method to modify the default behavior when creating materials.
  60468. * @param context The context when loading the asset
  60469. * @param material The glTF material property
  60470. * @param babylonDrawMode The draw mode for the Babylon material
  60471. * @returns The Babylon material or null if not handled
  60472. */
  60473. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  60474. /**
  60475. * Define this method to modify the default behavior when loading material properties.
  60476. * @param context The context when loading the asset
  60477. * @param material The glTF material property
  60478. * @param babylonMaterial The Babylon material
  60479. * @returns A promise that resolves when the load is complete or null if not handled
  60480. */
  60481. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  60482. /**
  60483. * Define this method to modify the default behavior when loading texture infos.
  60484. * @param context The context when loading the asset
  60485. * @param textureInfo The glTF texture info property
  60486. * @param assign A function called synchronously after parsing the glTF properties
  60487. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  60488. */
  60489. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  60490. /**
  60491. * Define this method to modify the default behavior when loading animations.
  60492. * @param context The context when loading the asset
  60493. * @param animation The glTF animation property
  60494. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  60495. */
  60496. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  60497. /**
  60498. * Define this method to modify the default behavior when loading uris.
  60499. * @param context The context when loading the asset
  60500. * @param property The glTF property associated with the uri
  60501. * @param uri The uri to load
  60502. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  60503. */ loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  60504. }
  60505. }
  60506. declare module BABYLON.GLTF2 {
  60507. /**
  60508. * Helper class for working with arrays when loading the glTF asset
  60509. */
  60510. export class ArrayItem {
  60511. /**
  60512. * Gets an item from the given array.
  60513. * @param context The context when loading the asset
  60514. * @param array The array to get the item from
  60515. * @param index The index to the array
  60516. * @returns The array item
  60517. */
  60518. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  60519. /**
  60520. * Assign an `index` field to each item of the given array.
  60521. * @param array The array of items
  60522. */
  60523. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  60524. }
  60525. /**
  60526. * The glTF 2.0 loader
  60527. */
  60528. export class GLTFLoader implements IGLTFLoader {
  60529. /** @hidden */ completePromises: Promise<any>[];
  60530. private _disposed;
  60531. private _parent;
  60532. private _state;
  60533. private _extensions;
  60534. private _rootUrl;
  60535. private _fileName;
  60536. private _uniqueRootUrl;
  60537. private _gltf;
  60538. private _babylonScene;
  60539. private _rootBabylonMesh;
  60540. private _defaultBabylonMaterialData;
  60541. private _progressCallback?;
  60542. private _requests;
  60543. private static readonly _DefaultSampler;
  60544. private static _ExtensionNames;
  60545. private static _ExtensionFactories;
  60546. /**
  60547. * Registers a loader extension.
  60548. * @param name The name of the loader extension.
  60549. * @param factory The factory function that creates the loader extension.
  60550. */
  60551. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  60552. /**
  60553. * Unregisters a loader extension.
  60554. * @param name The name of the loader extenion.
  60555. * @returns A boolean indicating whether the extension has been unregistered
  60556. */
  60557. static UnregisterExtension(name: string): boolean;
  60558. /**
  60559. * Gets the loader state.
  60560. */
  60561. readonly state: Nullable<GLTFLoaderState>;
  60562. /**
  60563. * The glTF object parsed from the JSON.
  60564. */
  60565. readonly gltf: IGLTF;
  60566. /**
  60567. * The Babylon scene when loading the asset.
  60568. */
  60569. readonly babylonScene: Scene;
  60570. /**
  60571. * The root Babylon mesh when loading the asset.
  60572. */
  60573. readonly rootBabylonMesh: Mesh;
  60574. /** @hidden */
  60575. constructor(parent: GLTFFileLoader);
  60576. /** @hidden */
  60577. dispose(): void;
  60578. /** @hidden */
  60579. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  60580. meshes: AbstractMesh[];
  60581. particleSystems: IParticleSystem[];
  60582. skeletons: Skeleton[];
  60583. animationGroups: AnimationGroup[];
  60584. }>;
  60585. /** @hidden */
  60586. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  60587. private _loadAsync;
  60588. private _loadData;
  60589. private _setupData;
  60590. private _loadExtensions;
  60591. private _checkExtensions;
  60592. private _setState;
  60593. private _createRootNode;
  60594. /**
  60595. * Loads a glTF scene.
  60596. * @param context The context when loading the asset
  60597. * @param scene The glTF scene property
  60598. * @returns A promise that resolves when the load is complete
  60599. */
  60600. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  60601. private _forEachPrimitive;
  60602. private _getMeshes;
  60603. private _getSkeletons;
  60604. private _getAnimationGroups;
  60605. private _startAnimations;
  60606. /**
  60607. * Loads a glTF node.
  60608. * @param context The context when loading the asset
  60609. * @param node The glTF node property
  60610. * @param assign A function called synchronously after parsing the glTF properties
  60611. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  60612. */
  60613. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  60614. private _loadMeshAsync;
  60615. private _loadMeshPrimitiveAsync;
  60616. private _loadVertexDataAsync;
  60617. private _createMorphTargets;
  60618. private _loadMorphTargetsAsync;
  60619. private _loadMorphTargetVertexDataAsync;
  60620. private static _LoadTransform;
  60621. private _loadSkinAsync;
  60622. private _loadBones;
  60623. private _loadBone;
  60624. private _loadSkinInverseBindMatricesDataAsync;
  60625. private _updateBoneMatrices;
  60626. private _getNodeMatrix;
  60627. /**
  60628. * Loads a glTF camera.
  60629. * @param context The context when loading the asset
  60630. * @param camera The glTF camera property
  60631. * @param assign A function called synchronously after parsing the glTF properties
  60632. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  60633. */
  60634. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  60635. private _loadAnimationsAsync;
  60636. /**
  60637. * Loads a glTF animation.
  60638. * @param context The context when loading the asset
  60639. * @param animation The glTF animation property
  60640. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  60641. */
  60642. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  60643. private _loadAnimationChannelAsync;
  60644. private _loadAnimationSamplerAsync;
  60645. private _loadBufferAsync;
  60646. /**
  60647. * Loads a glTF buffer view.
  60648. * @param context The context when loading the asset
  60649. * @param bufferView The glTF buffer view property
  60650. * @returns A promise that resolves with the loaded data when the load is complete
  60651. */
  60652. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  60653. private _loadIndicesAccessorAsync;
  60654. private _loadFloatAccessorAsync;
  60655. private _loadVertexBufferViewAsync;
  60656. private _loadVertexAccessorAsync;
  60657. private _loadMaterialMetallicRoughnessPropertiesAsync;
  60658. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  60659. private _createDefaultMaterial;
  60660. /**
  60661. * Creates a Babylon material from a glTF material.
  60662. * @param context The context when loading the asset
  60663. * @param material The glTF material property
  60664. * @param babylonDrawMode The draw mode for the Babylon material
  60665. * @returns The Babylon material
  60666. */
  60667. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  60668. /**
  60669. * Loads properties from a glTF material into a Babylon material.
  60670. * @param context The context when loading the asset
  60671. * @param material The glTF material property
  60672. * @param babylonMaterial The Babylon material
  60673. * @returns A promise that resolves when the load is complete
  60674. */
  60675. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  60676. /**
  60677. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  60678. * @param context The context when loading the asset
  60679. * @param material The glTF material property
  60680. * @param babylonMaterial The Babylon material
  60681. * @returns A promise that resolves when the load is complete
  60682. */
  60683. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  60684. /**
  60685. * Loads the alpha properties from a glTF material into a Babylon material.
  60686. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  60687. * @param context The context when loading the asset
  60688. * @param material The glTF material property
  60689. * @param babylonMaterial The Babylon material
  60690. */
  60691. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  60692. /**
  60693. * Loads a glTF texture info.
  60694. * @param context The context when loading the asset
  60695. * @param textureInfo The glTF texture info property
  60696. * @param assign A function called synchronously after parsing the glTF properties
  60697. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  60698. */
  60699. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  60700. private _loadTextureAsync;
  60701. private _loadSampler;
  60702. /**
  60703. * Loads a glTF image.
  60704. * @param context The context when loading the asset
  60705. * @param image The glTF image property
  60706. * @returns A promise that resolves with the loaded data when the load is complete
  60707. */
  60708. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  60709. /**
  60710. * Loads a glTF uri.
  60711. * @param context The context when loading the asset
  60712. * @param property The glTF property associated with the uri
  60713. * @param uri The base64 or relative uri
  60714. * @returns A promise that resolves with the loaded data when the load is complete
  60715. */
  60716. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  60717. private _onProgress;
  60718. /**
  60719. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  60720. * @param babylonObject the Babylon object with metadata
  60721. * @param pointer the JSON pointer
  60722. */
  60723. static AddPointerMetadata(babylonObject: {
  60724. metadata: any;
  60725. }, pointer: string): void;
  60726. private static _GetTextureWrapMode;
  60727. private static _GetTextureSamplingMode;
  60728. private static _GetTypedArray;
  60729. private static _GetNumComponents;
  60730. private static _ValidateUri;
  60731. private static _GetDrawMode;
  60732. private _compileMaterialsAsync;
  60733. private _compileShadowGeneratorsAsync;
  60734. private _forEachExtensions;
  60735. private _applyExtensions;
  60736. private _extensionsOnLoading;
  60737. private _extensionsOnReady;
  60738. private _extensionsLoadSceneAsync;
  60739. private _extensionsLoadNodeAsync;
  60740. private _extensionsLoadCameraAsync;
  60741. private _extensionsLoadVertexDataAsync;
  60742. private _extensionsLoadMaterialAsync;
  60743. private _extensionsCreateMaterial;
  60744. private _extensionsLoadMaterialPropertiesAsync;
  60745. private _extensionsLoadTextureInfoAsync;
  60746. private _extensionsLoadAnimationAsync;
  60747. private _extensionsLoadUriAsync;
  60748. /**
  60749. * Helper method called by a loader extension to load an glTF extension.
  60750. * @param context The context when loading the asset
  60751. * @param property The glTF property to load the extension from
  60752. * @param extensionName The name of the extension to load
  60753. * @param actionAsync The action to run
  60754. * @returns The promise returned by actionAsync or null if the extension does not exist
  60755. */
  60756. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  60757. /**
  60758. * Helper method called by a loader extension to load a glTF extra.
  60759. * @param context The context when loading the asset
  60760. * @param property The glTF property to load the extra from
  60761. * @param extensionName The name of the extension to load
  60762. * @param actionAsync The action to run
  60763. * @returns The promise returned by actionAsync or null if the extra does not exist
  60764. */
  60765. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  60766. /**
  60767. * Increments the indentation level and logs a message.
  60768. * @param message The message to log
  60769. */
  60770. logOpen(message: string): void;
  60771. /**
  60772. * Decrements the indentation level.
  60773. */
  60774. logClose(): void;
  60775. /**
  60776. * Logs a message
  60777. * @param message The message to log
  60778. */
  60779. log(message: string): void;
  60780. /**
  60781. * Starts a performance counter.
  60782. * @param counterName The name of the performance counter
  60783. */
  60784. startPerformanceCounter(counterName: string): void;
  60785. /**
  60786. * Ends a performance counter.
  60787. * @param counterName The name of the performance counter
  60788. */
  60789. endPerformanceCounter(counterName: string): void;
  60790. }
  60791. }
  60792. declare module BABYLON.GLTF2.Loader.Extensions {
  60793. /**
  60794. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  60795. */
  60796. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  60797. /** The name of this extension. */
  60798. readonly name: string;
  60799. /** Defines whether this extension is enabled. */
  60800. enabled: boolean;
  60801. private _loader;
  60802. private _lights?;
  60803. /** @hidden */
  60804. constructor(loader: GLTFLoader);
  60805. /** @hidden */
  60806. dispose(): void;
  60807. /** @hidden */
  60808. onLoading(): void;
  60809. /** @hidden */
  60810. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  60811. private _loadLightAsync;
  60812. }
  60813. }
  60814. declare module BABYLON.GLTF2.Loader.Extensions {
  60815. /**
  60816. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  60817. */
  60818. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  60819. /** The name of this extension. */
  60820. readonly name: string;
  60821. /** Defines whether this extension is enabled. */
  60822. enabled: boolean;
  60823. private _loader;
  60824. private _dracoCompression?;
  60825. /** @hidden */
  60826. constructor(loader: GLTFLoader);
  60827. /** @hidden */
  60828. dispose(): void;
  60829. /** @hidden */ loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  60830. }
  60831. }
  60832. declare module BABYLON.GLTF2.Loader.Extensions {
  60833. /**
  60834. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  60835. */
  60836. export class KHR_lights implements IGLTFLoaderExtension {
  60837. /** The name of this extension. */
  60838. readonly name: string;
  60839. /** Defines whether this extension is enabled. */
  60840. enabled: boolean;
  60841. private _loader;
  60842. private _lights?;
  60843. /** @hidden */
  60844. constructor(loader: GLTFLoader);
  60845. /** @hidden */
  60846. dispose(): void;
  60847. /** @hidden */
  60848. onLoading(): void;
  60849. /** @hidden */
  60850. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  60851. }
  60852. }
  60853. declare module BABYLON.GLTF2.Loader.Extensions {
  60854. /**
  60855. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  60856. */
  60857. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  60858. /** The name of this extension. */
  60859. readonly name: string;
  60860. /** Defines whether this extension is enabled. */
  60861. enabled: boolean;
  60862. private _loader;
  60863. /** @hidden */
  60864. constructor(loader: GLTFLoader);
  60865. /** @hidden */
  60866. dispose(): void;
  60867. /** @hidden */
  60868. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  60869. private _loadSpecularGlossinessPropertiesAsync;
  60870. }
  60871. }
  60872. declare module BABYLON.GLTF2.Loader.Extensions {
  60873. /**
  60874. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  60875. */
  60876. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  60877. /** The name of this extension. */
  60878. readonly name: string;
  60879. /** Defines whether this extension is enabled. */
  60880. enabled: boolean;
  60881. private _loader;
  60882. /** @hidden */
  60883. constructor(loader: GLTFLoader);
  60884. /** @hidden */
  60885. dispose(): void;
  60886. /** @hidden */
  60887. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  60888. private _loadUnlitPropertiesAsync;
  60889. }
  60890. }
  60891. declare module BABYLON.GLTF2.Loader.Extensions {
  60892. /**
  60893. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  60894. */
  60895. export class KHR_texture_transform implements IGLTFLoaderExtension {
  60896. /** The name of this extension. */
  60897. readonly name: string;
  60898. /** Defines whether this extension is enabled. */
  60899. enabled: boolean;
  60900. private _loader;
  60901. /** @hidden */
  60902. constructor(loader: GLTFLoader);
  60903. /** @hidden */
  60904. dispose(): void;
  60905. /** @hidden */
  60906. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  60907. }
  60908. }
  60909. declare module BABYLON.GLTF2.Loader.Extensions {
  60910. /**
  60911. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  60912. */
  60913. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  60914. /** The name of this extension. */
  60915. readonly name: string;
  60916. /** Defines whether this extension is enabled. */
  60917. enabled: boolean;
  60918. private _loader;
  60919. private _clips;
  60920. private _emitters;
  60921. /** @hidden */
  60922. constructor(loader: GLTFLoader);
  60923. /** @hidden */
  60924. dispose(): void;
  60925. /** @hidden */
  60926. onLoading(): void;
  60927. /** @hidden */
  60928. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  60929. /** @hidden */
  60930. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  60931. /** @hidden */
  60932. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  60933. private _loadClipAsync;
  60934. private _loadEmitterAsync;
  60935. private _getEventAction;
  60936. private _loadAnimationEventAsync;
  60937. }
  60938. }
  60939. declare module BABYLON.GLTF2.Loader.Extensions {
  60940. /**
  60941. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  60942. */
  60943. export class MSFT_lod implements IGLTFLoaderExtension {
  60944. /** The name of this extension. */
  60945. readonly name: string;
  60946. /** Defines whether this extension is enabled. */
  60947. enabled: boolean;
  60948. /**
  60949. * Maximum number of LODs to load, starting from the lowest LOD.
  60950. */
  60951. maxLODsToLoad: number;
  60952. /**
  60953. * Observable raised when all node LODs of one level are loaded.
  60954. * The event data is the index of the loaded LOD starting from zero.
  60955. * Dispose the loader to cancel the loading of the next level of LODs.
  60956. */
  60957. onNodeLODsLoadedObservable: Observable<number>;
  60958. /**
  60959. * Observable raised when all material LODs of one level are loaded.
  60960. * The event data is the index of the loaded LOD starting from zero.
  60961. * Dispose the loader to cancel the loading of the next level of LODs.
  60962. */
  60963. onMaterialLODsLoadedObservable: Observable<number>;
  60964. private _loader;
  60965. private _nodeIndexLOD;
  60966. private _nodeSignalLODs;
  60967. private _nodePromiseLODs;
  60968. private _materialIndexLOD;
  60969. private _materialSignalLODs;
  60970. private _materialPromiseLODs;
  60971. /** @hidden */
  60972. constructor(loader: GLTFLoader);
  60973. /** @hidden */
  60974. dispose(): void;
  60975. /** @hidden */
  60976. onReady(): void;
  60977. /** @hidden */
  60978. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  60979. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  60980. /** @hidden */ loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  60981. /**
  60982. * Gets an array of LOD properties from lowest to highest.
  60983. */
  60984. private _getLODs;
  60985. private _disposeUnusedMaterials;
  60986. }
  60987. }
  60988. declare module BABYLON.GLTF2.Loader.Extensions {
  60989. /** @hidden */
  60990. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  60991. readonly name: string;
  60992. enabled: boolean;
  60993. private _loader;
  60994. constructor(loader: GLTFLoader);
  60995. dispose(): void;
  60996. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  60997. }
  60998. }
  60999. declare module BABYLON.GLTF2.Loader.Extensions {
  61000. /** @hidden */
  61001. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  61002. readonly name: string;
  61003. enabled: boolean;
  61004. private _loader;
  61005. constructor(loader: GLTFLoader);
  61006. dispose(): void;
  61007. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61008. }
  61009. }
  61010. declare module BABYLON {
  61011. /**
  61012. * Class reading and parsing the MTL file bundled with the obj file.
  61013. */
  61014. export class MTLFileLoader {
  61015. /**
  61016. * All material loaded from the mtl will be set here
  61017. */
  61018. materials: StandardMaterial[];
  61019. /**
  61020. * This function will read the mtl file and create each material described inside
  61021. * This function could be improve by adding :
  61022. * -some component missing (Ni, Tf...)
  61023. * -including the specific options available
  61024. *
  61025. * @param scene defines the scene the material will be created in
  61026. * @param data defines the mtl data to parse
  61027. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  61028. */
  61029. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  61030. /**
  61031. * Gets the texture for the material.
  61032. *
  61033. * If the material is imported from input file,
  61034. * We sanitize the url to ensure it takes the textre from aside the material.
  61035. *
  61036. * @param rootUrl The root url to load from
  61037. * @param value The value stored in the mtl
  61038. * @return The Texture
  61039. */
  61040. private static _getTexture;
  61041. }
  61042. /**
  61043. * Options for loading OBJ/MTL files
  61044. */
  61045. type MeshLoadOptions = {
  61046. /**
  61047. * Defines if UVs are optimized by default during load.
  61048. */
  61049. OptimizeWithUV: boolean;
  61050. /**
  61051. * Invert model on y-axis (does a model scaling inversion)
  61052. */
  61053. InvertY: boolean;
  61054. /**
  61055. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  61056. */
  61057. ImportVertexColors: boolean;
  61058. /**
  61059. * Compute the normals for the model, even if normals are present in the file.
  61060. */
  61061. ComputeNormals: boolean;
  61062. /**
  61063. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  61064. */
  61065. SkipMaterials: boolean;
  61066. /**
  61067. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  61068. */
  61069. MaterialLoadingFailsSilently: boolean;
  61070. };
  61071. /**
  61072. * OBJ file type loader.
  61073. * This is a babylon scene loader plugin.
  61074. */
  61075. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  61076. /**
  61077. * Defines if UVs are optimized by default during load.
  61078. */
  61079. static OPTIMIZE_WITH_UV: boolean;
  61080. /**
  61081. * Invert model on y-axis (does a model scaling inversion)
  61082. */
  61083. static INVERT_Y: boolean;
  61084. /**
  61085. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  61086. */
  61087. static IMPORT_VERTEX_COLORS: boolean;
  61088. /**
  61089. * Compute the normals for the model, even if normals are present in the file.
  61090. */
  61091. static COMPUTE_NORMALS: boolean;
  61092. /**
  61093. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  61094. */
  61095. static SKIP_MATERIALS: boolean;
  61096. /**
  61097. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  61098. *
  61099. * Defaults to true for backwards compatibility.
  61100. */
  61101. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  61102. /**
  61103. * Defines the name of the plugin.
  61104. */
  61105. name: string;
  61106. /**
  61107. * Defines the extension the plugin is able to load.
  61108. */
  61109. extensions: string;
  61110. /** @hidden */
  61111. obj: RegExp;
  61112. /** @hidden */
  61113. group: RegExp;
  61114. /** @hidden */
  61115. mtllib: RegExp;
  61116. /** @hidden */
  61117. usemtl: RegExp;
  61118. /** @hidden */
  61119. smooth: RegExp;
  61120. /** @hidden */
  61121. vertexPattern: RegExp;
  61122. /** @hidden */
  61123. normalPattern: RegExp;
  61124. /** @hidden */
  61125. uvPattern: RegExp;
  61126. /** @hidden */
  61127. facePattern1: RegExp;
  61128. /** @hidden */
  61129. facePattern2: RegExp;
  61130. /** @hidden */
  61131. facePattern3: RegExp;
  61132. /** @hidden */
  61133. facePattern4: RegExp;
  61134. /** @hidden */
  61135. facePattern5: RegExp;
  61136. private _meshLoadOptions;
  61137. /**
  61138. * Creates loader for .OBJ files
  61139. *
  61140. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  61141. */
  61142. constructor(meshLoadOptions?: MeshLoadOptions);
  61143. private static readonly currentMeshLoadOptions;
  61144. /**
  61145. * Calls synchronously the MTL file attached to this obj.
  61146. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  61147. * Without this function materials are not displayed in the first frame (but displayed after).
  61148. * In consequence it is impossible to get material information in your HTML file
  61149. *
  61150. * @param url The URL of the MTL file
  61151. * @param rootUrl
  61152. * @param onSuccess Callback function to be called when the MTL file is loaded
  61153. * @private
  61154. */
  61155. private _loadMTL;
  61156. /**
  61157. * Instantiates a OBJ file loader plugin.
  61158. * @returns the created plugin
  61159. */
  61160. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  61161. /**
  61162. * If the data string can be loaded directly.
  61163. *
  61164. * @param data string containing the file data
  61165. * @returns if the data can be loaded directly
  61166. */
  61167. canDirectLoad(data: string): boolean;
  61168. /**
  61169. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  61170. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  61171. * @param scene the scene the meshes should be added to
  61172. * @param data the OBJ data to load
  61173. * @param rootUrl root url to load from
  61174. * @param onProgress event that fires when loading progress has occured
  61175. * @param fileName Defines the name of the file to load
  61176. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  61177. */
  61178. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  61179. meshes: AbstractMesh[];
  61180. particleSystems: IParticleSystem[];
  61181. skeletons: Skeleton[];
  61182. animationGroups: AnimationGroup[];
  61183. }>;
  61184. /**
  61185. * Imports all objects from the loaded OBJ data and adds them to the scene
  61186. * @param scene the scene the objects should be added to
  61187. * @param data the OBJ data to load
  61188. * @param rootUrl root url to load from
  61189. * @param onProgress event that fires when loading progress has occured
  61190. * @param fileName Defines the name of the file to load
  61191. * @returns a promise which completes when objects have been loaded to the scene
  61192. */
  61193. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  61194. /**
  61195. * Load into an asset container.
  61196. * @param scene The scene to load into
  61197. * @param data The data to import
  61198. * @param rootUrl The root url for scene and resources
  61199. * @param onProgress The callback when the load progresses
  61200. * @param fileName Defines the name of the file to load
  61201. * @returns The loaded asset container
  61202. */
  61203. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  61204. /**
  61205. * Read the OBJ file and create an Array of meshes.
  61206. * Each mesh contains all information given by the OBJ and the MTL file.
  61207. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  61208. *
  61209. * @param meshesNames
  61210. * @param scene Scene The scene where are displayed the data
  61211. * @param data String The content of the obj file
  61212. * @param rootUrl String The path to the folder
  61213. * @returns Array<AbstractMesh>
  61214. * @private
  61215. */
  61216. private _parseSolid;
  61217. }
  61218. }
  61219. declare module BABYLON {
  61220. /**
  61221. * STL file type loader.
  61222. * This is a babylon scene loader plugin.
  61223. */
  61224. export class STLFileLoader implements ISceneLoaderPlugin {
  61225. /** @hidden */
  61226. solidPattern: RegExp;
  61227. /** @hidden */
  61228. facetsPattern: RegExp;
  61229. /** @hidden */
  61230. normalPattern: RegExp;
  61231. /** @hidden */
  61232. vertexPattern: RegExp;
  61233. /**
  61234. * Defines the name of the plugin.
  61235. */
  61236. name: string;
  61237. /**
  61238. * Defines the extensions the stl loader is able to load.
  61239. * force data to come in as an ArrayBuffer
  61240. * we'll convert to string if it looks like it's an ASCII .stl
  61241. */
  61242. extensions: ISceneLoaderPluginExtensions;
  61243. /**
  61244. * Import meshes into a scene.
  61245. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  61246. * @param scene The scene to import into
  61247. * @param data The data to import
  61248. * @param rootUrl The root url for scene and resources
  61249. * @param meshes The meshes array to import into
  61250. * @param particleSystems The particle systems array to import into
  61251. * @param skeletons The skeletons array to import into
  61252. * @param onError The callback when import fails
  61253. * @returns True if successful or false otherwise
  61254. */
  61255. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  61256. /**
  61257. * Load into a scene.
  61258. * @param scene The scene to load into
  61259. * @param data The data to import
  61260. * @param rootUrl The root url for scene and resources
  61261. * @param onError The callback when import fails
  61262. * @returns true if successful or false otherwise
  61263. */
  61264. load(scene: Scene, data: any, rootUrl: string): boolean;
  61265. /**
  61266. * Load into an asset container.
  61267. * @param scene The scene to load into
  61268. * @param data The data to import
  61269. * @param rootUrl The root url for scene and resources
  61270. * @param onError The callback when import fails
  61271. * @returns The loaded asset container
  61272. */
  61273. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  61274. private _isBinary;
  61275. private _parseBinary;
  61276. private _parseASCII;
  61277. }
  61278. }
  61279. declare module BABYLON {
  61280. /**
  61281. * Class for generating OBJ data from a Babylon scene.
  61282. */
  61283. export class OBJExport {
  61284. /**
  61285. * Exports the geometry of a Mesh array in .OBJ file format (text)
  61286. * @param mesh defines the list of meshes to serialize
  61287. * @param materials defines if materials should be exported
  61288. * @param matlibname defines the name of the associated mtl file
  61289. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  61290. * @returns the OBJ content
  61291. */
  61292. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  61293. /**
  61294. * Exports the material(s) of a mesh in .MTL file format (text)
  61295. * @param mesh defines the mesh to extract the material from
  61296. * @returns the mtl content
  61297. */
  61298. static MTL(mesh: Mesh): string;
  61299. }
  61300. }
  61301. declare module BABYLON {
  61302. /** @hidden */
  61303. export var __IGLTFExporterExtension: number;
  61304. /**
  61305. * Interface for extending the exporter
  61306. * @hidden
  61307. */
  61308. export interface IGLTFExporterExtension {
  61309. /**
  61310. * The name of this extension
  61311. */
  61312. readonly name: string;
  61313. /**
  61314. * Defines whether this extension is enabled
  61315. */
  61316. enabled: boolean;
  61317. /**
  61318. * Defines whether this extension is required
  61319. */
  61320. required: boolean;
  61321. }
  61322. }
  61323. declare module BABYLON.GLTF2.Exporter {
  61324. /** @hidden */
  61325. export var __IGLTFExporterExtensionV2: number;
  61326. /**
  61327. * Interface for a glTF exporter extension
  61328. * @hidden
  61329. */
  61330. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  61331. /**
  61332. * Define this method to modify the default behavior before exporting a texture
  61333. * @param context The context when loading the asset
  61334. * @param babylonTexture The glTF texture info property
  61335. * @param mimeType The mime-type of the generated image
  61336. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  61337. */
  61338. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  61339. /**
  61340. * Define this method to modify the default behavior when exporting texture info
  61341. * @param context The context when loading the asset
  61342. * @param meshPrimitive glTF mesh primitive
  61343. * @param babylonSubMesh Babylon submesh
  61344. * @param binaryWriter glTF serializer binary writer instance
  61345. * @returns nullable IMeshPrimitive promise
  61346. */
  61347. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  61348. /**
  61349. * Define this method to modify the default behavior when exporting a node
  61350. * @param context The context when exporting the node
  61351. * @param node glTF node
  61352. * @param babylonNode BabylonJS node
  61353. * @returns nullable INode promise
  61354. */
  61355. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  61356. /**
  61357. * Called after the exporter state changes to EXPORTING
  61358. */
  61359. onExporting?(): void;
  61360. }
  61361. }
  61362. declare module BABYLON.GLTF2.Exporter {
  61363. /**
  61364. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  61365. * @hidden
  61366. */
  61367. export class _GLTFMaterialExporter {
  61368. /**
  61369. * Represents the dielectric specular values for R, G and B
  61370. */
  61371. private static readonly _DielectricSpecular;
  61372. /**
  61373. * Allows the maximum specular power to be defined for material calculations
  61374. */
  61375. private static readonly _MaxSpecularPower;
  61376. /**
  61377. * Mapping to store textures
  61378. */
  61379. private _textureMap;
  61380. /**
  61381. * Numeric tolerance value
  61382. */
  61383. private static readonly _Epsilon;
  61384. /**
  61385. * Reference to the glTF Exporter
  61386. */
  61387. private _exporter;
  61388. constructor(exporter: _Exporter);
  61389. /**
  61390. * Specifies if two colors are approximately equal in value
  61391. * @param color1 first color to compare to
  61392. * @param color2 second color to compare to
  61393. * @param epsilon threshold value
  61394. */
  61395. private static FuzzyEquals;
  61396. /**
  61397. * Gets the materials from a Babylon scene and converts them to glTF materials
  61398. * @param scene babylonjs scene
  61399. * @param mimeType texture mime type
  61400. * @param images array of images
  61401. * @param textures array of textures
  61402. * @param materials array of materials
  61403. * @param imageData mapping of texture names to base64 textures
  61404. * @param hasTextureCoords specifies if texture coordinates are present on the material
  61405. */ convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61406. /**
  61407. * Makes a copy of the glTF material without the texture parameters
  61408. * @param originalMaterial original glTF material
  61409. * @returns glTF material without texture parameters
  61410. */ stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  61411. /**
  61412. * Specifies if the material has any texture parameters present
  61413. * @param material glTF Material
  61414. * @returns boolean specifying if texture parameters are present
  61415. */ hasTexturesPresent(material: IMaterial): boolean;
  61416. /**
  61417. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  61418. * @param babylonStandardMaterial
  61419. * @returns glTF Metallic Roughness Material representation
  61420. */ convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  61421. /**
  61422. * Computes the metallic factor
  61423. * @param diffuse diffused value
  61424. * @param specular specular value
  61425. * @param oneMinusSpecularStrength one minus the specular strength
  61426. * @returns metallic value
  61427. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  61428. /**
  61429. * Gets the glTF alpha mode from the Babylon Material
  61430. * @param babylonMaterial Babylon Material
  61431. * @returns The Babylon alpha mode value
  61432. */ getAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  61433. /**
  61434. * Converts a Babylon Standard Material to a glTF Material
  61435. * @param babylonStandardMaterial BJS Standard Material
  61436. * @param mimeType mime type to use for the textures
  61437. * @param images array of glTF image interfaces
  61438. * @param textures array of glTF texture interfaces
  61439. * @param materials array of glTF material interfaces
  61440. * @param imageData map of image file name to data
  61441. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61442. */ convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61443. /**
  61444. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  61445. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  61446. * @param mimeType mime type to use for the textures
  61447. * @param images array of glTF image interfaces
  61448. * @param textures array of glTF texture interfaces
  61449. * @param materials array of glTF material interfaces
  61450. * @param imageData map of image file name to data
  61451. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61452. */ convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61453. /**
  61454. * Converts an image typed array buffer to a base64 image
  61455. * @param buffer typed array buffer
  61456. * @param width width of the image
  61457. * @param height height of the image
  61458. * @param mimeType mimetype of the image
  61459. * @returns base64 image string
  61460. */
  61461. private _createBase64FromCanvasAsync;
  61462. /**
  61463. * Generates a white texture based on the specified width and height
  61464. * @param width width of the texture in pixels
  61465. * @param height height of the texture in pixels
  61466. * @param scene babylonjs scene
  61467. * @returns white texture
  61468. */
  61469. private _createWhiteTexture;
  61470. /**
  61471. * Resizes the two source textures to the same dimensions. If a texture is null, a default white texture is generated. If both textures are null, returns null
  61472. * @param texture1 first texture to resize
  61473. * @param texture2 second texture to resize
  61474. * @param scene babylonjs scene
  61475. * @returns resized textures or null
  61476. */
  61477. private _resizeTexturesToSameDimensions;
  61478. /**
  61479. * Converts an array of pixels to a Float32Array
  61480. * Throws an error if the pixel format is not supported
  61481. * @param pixels - array buffer containing pixel values
  61482. * @returns Float32 of pixels
  61483. */
  61484. private _convertPixelArrayToFloat32;
  61485. /**
  61486. * Convert Specular Glossiness Textures to Metallic Roughness
  61487. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  61488. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  61489. * @param diffuseTexture texture used to store diffuse information
  61490. * @param specularGlossinessTexture texture used to store specular and glossiness information
  61491. * @param factors specular glossiness material factors
  61492. * @param mimeType the mime type to use for the texture
  61493. * @returns pbr metallic roughness interface or null
  61494. */
  61495. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  61496. /**
  61497. * Converts specular glossiness material properties to metallic roughness
  61498. * @param specularGlossiness interface with specular glossiness material properties
  61499. * @returns interface with metallic roughness material properties
  61500. */
  61501. private _convertSpecularGlossinessToMetallicRoughness;
  61502. /**
  61503. * Calculates the surface reflectance, independent of lighting conditions
  61504. * @param color Color source to calculate brightness from
  61505. * @returns number representing the perceived brightness, or zero if color is undefined
  61506. */
  61507. private _getPerceivedBrightness;
  61508. /**
  61509. * Returns the maximum color component value
  61510. * @param color
  61511. * @returns maximum color component value, or zero if color is null or undefined
  61512. */
  61513. private _getMaxComponent;
  61514. /**
  61515. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  61516. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61517. * @param mimeType mime type to use for the textures
  61518. * @param images array of glTF image interfaces
  61519. * @param textures array of glTF texture interfaces
  61520. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  61521. * @param imageData map of image file name to data
  61522. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61523. * @returns glTF PBR Metallic Roughness factors
  61524. */
  61525. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  61526. private _getGLTFTextureSampler;
  61527. private _getGLTFTextureWrapMode;
  61528. private _getGLTFTextureWrapModesSampler;
  61529. /**
  61530. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  61531. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61532. * @param mimeType mime type to use for the textures
  61533. * @param images array of glTF image interfaces
  61534. * @param textures array of glTF texture interfaces
  61535. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  61536. * @param imageData map of image file name to data
  61537. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61538. * @returns glTF PBR Metallic Roughness factors
  61539. */
  61540. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  61541. /**
  61542. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  61543. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61544. * @param mimeType mime type to use for the textures
  61545. * @param images array of glTF image interfaces
  61546. * @param textures array of glTF texture interfaces
  61547. * @param materials array of glTF material interfaces
  61548. * @param imageData map of image file name to data
  61549. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61550. */ convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61551. private setMetallicRoughnessPbrMaterial;
  61552. private getPixelsFromTexture;
  61553. /**
  61554. * Extracts a texture from a Babylon texture into file data and glTF data
  61555. * @param babylonTexture Babylon texture to extract
  61556. * @param mimeType Mime Type of the babylonTexture
  61557. * @return glTF texture info, or null if the texture format is not supported
  61558. */ exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  61559. /**
  61560. * Builds a texture from base64 string
  61561. * @param base64Texture base64 texture string
  61562. * @param baseTextureName Name to use for the texture
  61563. * @param mimeType image mime type for the texture
  61564. * @param images array of images
  61565. * @param textures array of textures
  61566. * @param imageData map of image data
  61567. * @returns glTF texture info, or null if the texture format is not supported
  61568. */
  61569. private _getTextureInfoFromBase64;
  61570. }
  61571. }
  61572. declare module BABYLON {
  61573. /**
  61574. * Class for holding and downloading glTF file data
  61575. */
  61576. export class GLTFData {
  61577. /**
  61578. * Object which contains the file name as the key and its data as the value
  61579. */
  61580. glTFFiles: {
  61581. [fileName: string]: string | Blob;
  61582. };
  61583. /**
  61584. * Initializes the glTF file object
  61585. */
  61586. constructor();
  61587. /**
  61588. * Downloads the glTF data as files based on their names and data
  61589. */
  61590. downloadFiles(): void;
  61591. }
  61592. }
  61593. declare module BABYLON {
  61594. /**
  61595. * Holds a collection of exporter options and parameters
  61596. */
  61597. export interface IExportOptions {
  61598. /**
  61599. * Function which indicates whether a babylon node should be exported or not
  61600. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  61601. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  61602. */
  61603. shouldExportNode?(node: Node): boolean;
  61604. /**
  61605. * The sample rate to bake animation curves
  61606. */
  61607. animationSampleRate?: number;
  61608. /**
  61609. * Begin serialization without waiting for the scene to be ready
  61610. */
  61611. exportWithoutWaitingForScene?: boolean;
  61612. }
  61613. /**
  61614. * Class for generating glTF data from a Babylon scene.
  61615. */
  61616. export class GLTF2Export {
  61617. /**
  61618. * Exports the geometry of the scene to .gltf file format asynchronously
  61619. * @param scene Babylon scene with scene hierarchy information
  61620. * @param filePrefix File prefix to use when generating the glTF file
  61621. * @param options Exporter options
  61622. * @returns Returns an object with a .gltf file and associates texture names
  61623. * as keys and their data and paths as values
  61624. */
  61625. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  61626. private static _PreExportAsync;
  61627. private static _PostExportAsync;
  61628. /**
  61629. * Exports the geometry of the scene to .glb file format asychronously
  61630. * @param scene Babylon scene with scene hierarchy information
  61631. * @param filePrefix File prefix to use when generating glb file
  61632. * @param options Exporter options
  61633. * @returns Returns an object with a .glb filename as key and data as value
  61634. */
  61635. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  61636. }
  61637. }
  61638. declare module BABYLON.GLTF2.Exporter {
  61639. /**
  61640. * @hidden
  61641. */
  61642. export class _GLTFUtilities {
  61643. /**
  61644. * Creates a buffer view based on the supplied arguments
  61645. * @param bufferIndex index value of the specified buffer
  61646. * @param byteOffset byte offset value
  61647. * @param byteLength byte length of the bufferView
  61648. * @param byteStride byte distance between conequential elements
  61649. * @param name name of the buffer view
  61650. * @returns bufferView for glTF
  61651. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  61652. /**
  61653. * Creates an accessor based on the supplied arguments
  61654. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  61655. * @param name The name of the accessor
  61656. * @param type The type of the accessor
  61657. * @param componentType The datatype of components in the attribute
  61658. * @param count The number of attributes referenced by this accessor
  61659. * @param byteOffset The offset relative to the start of the bufferView in bytes
  61660. * @param min Minimum value of each component in this attribute
  61661. * @param max Maximum value of each component in this attribute
  61662. * @returns accessor for glTF
  61663. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  61664. /**
  61665. * Calculates the minimum and maximum values of an array of position floats
  61666. * @param positions Positions array of a mesh
  61667. * @param vertexStart Starting vertex offset to calculate min and max values
  61668. * @param vertexCount Number of vertices to check for min and max values
  61669. * @returns min number array and max number array
  61670. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  61671. min: number[];
  61672. max: number[];
  61673. };
  61674. /**
  61675. * Converts a new right-handed Vector3
  61676. * @param vector vector3 array
  61677. * @returns right-handed Vector3
  61678. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  61679. /**
  61680. * Converts a Vector3 to right-handed
  61681. * @param vector Vector3 to convert to right-handed
  61682. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  61683. /**
  61684. * Converts a three element number array to right-handed
  61685. * @param vector number array to convert to right-handed
  61686. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  61687. /**
  61688. * Converts a new right-handed Vector3
  61689. * @param vector vector3 array
  61690. * @returns right-handed Vector3
  61691. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  61692. /**
  61693. * Converts a Vector3 to right-handed
  61694. * @param vector Vector3 to convert to right-handed
  61695. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  61696. /**
  61697. * Converts a three element number array to right-handed
  61698. * @param vector number array to convert to right-handed
  61699. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  61700. /**
  61701. * Converts a Vector4 to right-handed
  61702. * @param vector Vector4 to convert to right-handed
  61703. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  61704. /**
  61705. * Converts a Vector4 to right-handed
  61706. * @param vector Vector4 to convert to right-handed
  61707. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  61708. /**
  61709. * Converts a Quaternion to right-handed
  61710. * @param quaternion Source quaternion to convert to right-handed
  61711. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  61712. /**
  61713. * Converts a Quaternion to right-handed
  61714. * @param quaternion Source quaternion to convert to right-handed
  61715. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  61716. }
  61717. }
  61718. declare module BABYLON.GLTF2.Exporter {
  61719. /**
  61720. * Converts Babylon Scene into glTF 2.0.
  61721. * @hidden
  61722. */
  61723. export class _Exporter {
  61724. /**
  61725. * Stores the glTF to export
  61726. */ glTF: IGLTF;
  61727. /**
  61728. * Stores all generated buffer views, which represents views into the main glTF buffer data
  61729. */ bufferViews: IBufferView[];
  61730. /**
  61731. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  61732. */ accessors: IAccessor[];
  61733. /**
  61734. * Stores all the generated nodes, which contains transform and/or mesh information per node
  61735. */
  61736. private _nodes;
  61737. /**
  61738. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  61739. */
  61740. private _scenes;
  61741. /**
  61742. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  61743. */
  61744. private _meshes;
  61745. /**
  61746. * Stores all the generated material information, which represents the appearance of each primitive
  61747. */ materials: IMaterial[]; materialMap: {
  61748. [materialID: number]: number;
  61749. };
  61750. /**
  61751. * Stores all the generated texture information, which is referenced by glTF materials
  61752. */ textures: ITexture[];
  61753. /**
  61754. * Stores all the generated image information, which is referenced by glTF textures
  61755. */ images: IImage[];
  61756. /**
  61757. * Stores all the texture samplers
  61758. */ samplers: ISampler[];
  61759. /**
  61760. * Stores all the generated animation samplers, which is referenced by glTF animations
  61761. */
  61762. /**
  61763. * Stores the animations for glTF models
  61764. */
  61765. private _animations;
  61766. /**
  61767. * Stores the total amount of bytes stored in the glTF buffer
  61768. */
  61769. private _totalByteLength;
  61770. /**
  61771. * Stores a reference to the Babylon scene containing the source geometry and material information
  61772. */ babylonScene: Scene;
  61773. /**
  61774. * Stores a map of the image data, where the key is the file name and the value
  61775. * is the image data
  61776. */ imageData: {
  61777. [fileName: string]: {
  61778. data: Uint8Array;
  61779. mimeType: ImageMimeType;
  61780. };
  61781. };
  61782. /**
  61783. * Stores a map of the unique id of a node to its index in the node array
  61784. */
  61785. private _nodeMap;
  61786. /**
  61787. * Specifies if the Babylon scene should be converted to right-handed on export
  61788. */ convertToRightHandedSystem: boolean;
  61789. /**
  61790. * Baked animation sample rate
  61791. */
  61792. private _animationSampleRate;
  61793. /**
  61794. * Callback which specifies if a node should be exported or not
  61795. */
  61796. private _shouldExportNode;
  61797. private _localEngine; glTFMaterialExporter: _GLTFMaterialExporter;
  61798. private _extensions;
  61799. private static _ExtensionNames;
  61800. private static _ExtensionFactories;
  61801. private _applyExtensions; extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>; extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>; extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  61802. private _forEachExtensions;
  61803. private _extensionsOnExporting;
  61804. /**
  61805. * Load glTF serializer extensions
  61806. */
  61807. private _loadExtensions;
  61808. /**
  61809. * Creates a glTF Exporter instance, which can accept optional exporter options
  61810. * @param babylonScene Babylon scene object
  61811. * @param options Options to modify the behavior of the exporter
  61812. */
  61813. constructor(babylonScene: Scene, options?: IExportOptions);
  61814. /**
  61815. * Registers a glTF exporter extension
  61816. * @param name Name of the extension to export
  61817. * @param factory The factory function that creates the exporter extension
  61818. */
  61819. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  61820. /**
  61821. * Un-registers an exporter extension
  61822. * @param name The name fo the exporter extension
  61823. * @returns A boolean indicating whether the extension has been un-registered
  61824. */
  61825. static UnregisterExtension(name: string): boolean;
  61826. /**
  61827. * Lazy load a local engine with premultiplied alpha set to false
  61828. */ getLocalEngine(): Engine;
  61829. private reorderIndicesBasedOnPrimitiveMode;
  61830. /**
  61831. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  61832. * clock-wise during export to glTF
  61833. * @param submesh BabylonJS submesh
  61834. * @param primitiveMode Primitive mode of the mesh
  61835. * @param sideOrientation the winding order of the submesh
  61836. * @param vertexBufferKind The type of vertex attribute
  61837. * @param meshAttributeArray The vertex attribute data
  61838. * @param byteOffset The offset to the binary data
  61839. * @param binaryWriter The binary data for the glTF file
  61840. */
  61841. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  61842. /**
  61843. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  61844. * clock-wise during export to glTF
  61845. * @param submesh BabylonJS submesh
  61846. * @param primitiveMode Primitive mode of the mesh
  61847. * @param sideOrientation the winding order of the submesh
  61848. * @param vertexBufferKind The type of vertex attribute
  61849. * @param meshAttributeArray The vertex attribute data
  61850. * @param byteOffset The offset to the binary data
  61851. * @param binaryWriter The binary data for the glTF file
  61852. */
  61853. private reorderTriangleFillMode;
  61854. /**
  61855. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  61856. * clock-wise during export to glTF
  61857. * @param submesh BabylonJS submesh
  61858. * @param primitiveMode Primitive mode of the mesh
  61859. * @param sideOrientation the winding order of the submesh
  61860. * @param vertexBufferKind The type of vertex attribute
  61861. * @param meshAttributeArray The vertex attribute data
  61862. * @param byteOffset The offset to the binary data
  61863. * @param binaryWriter The binary data for the glTF file
  61864. */
  61865. private reorderTriangleStripDrawMode;
  61866. /**
  61867. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  61868. * clock-wise during export to glTF
  61869. * @param submesh BabylonJS submesh
  61870. * @param primitiveMode Primitive mode of the mesh
  61871. * @param sideOrientation the winding order of the submesh
  61872. * @param vertexBufferKind The type of vertex attribute
  61873. * @param meshAttributeArray The vertex attribute data
  61874. * @param byteOffset The offset to the binary data
  61875. * @param binaryWriter The binary data for the glTF file
  61876. */
  61877. private reorderTriangleFanMode;
  61878. /**
  61879. * Writes the vertex attribute data to binary
  61880. * @param vertices The vertices to write to the binary writer
  61881. * @param byteOffset The offset into the binary writer to overwrite binary data
  61882. * @param vertexAttributeKind The vertex attribute type
  61883. * @param meshAttributeArray The vertex attribute data
  61884. * @param binaryWriter The writer containing the binary data
  61885. */
  61886. private writeVertexAttributeData;
  61887. /**
  61888. * Writes mesh attribute data to a data buffer
  61889. * Returns the bytelength of the data
  61890. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  61891. * @param meshAttributeArray Array containing the attribute data
  61892. * @param binaryWriter The buffer to write the binary data to
  61893. * @param indices Used to specify the order of the vertex data
  61894. */
  61895. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  61896. /**
  61897. * Generates glTF json data
  61898. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  61899. * @param glTFPrefix Text to use when prefixing a glTF file
  61900. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  61901. * @returns json data as string
  61902. */
  61903. private generateJSON;
  61904. /**
  61905. * Generates data for .gltf and .bin files based on the glTF prefix string
  61906. * @param glTFPrefix Text to use when prefixing a glTF file
  61907. * @returns GLTFData with glTF file data
  61908. */ generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  61909. /**
  61910. * Creates a binary buffer for glTF
  61911. * @returns array buffer for binary data
  61912. */
  61913. private _generateBinaryAsync;
  61914. /**
  61915. * Pads the number to a multiple of 4
  61916. * @param num number to pad
  61917. * @returns padded number
  61918. */
  61919. private _getPadding;
  61920. /**
  61921. * Generates a glb file from the json and binary data
  61922. * Returns an object with the glb file name as the key and data as the value
  61923. * @param glTFPrefix
  61924. * @returns object with glb filename as key and data as value
  61925. */ generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  61926. /**
  61927. * Sets the TRS for each node
  61928. * @param node glTF Node for storing the transformation data
  61929. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  61930. */
  61931. private setNodeTransformation;
  61932. private getVertexBufferFromMesh;
  61933. /**
  61934. * Creates a bufferview based on the vertices type for the Babylon mesh
  61935. * @param kind Indicates the type of vertices data
  61936. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  61937. * @param binaryWriter The buffer to write the bufferview data to
  61938. */
  61939. private createBufferViewKind;
  61940. /**
  61941. * The primitive mode of the Babylon mesh
  61942. * @param babylonMesh The BabylonJS mesh
  61943. */
  61944. private getMeshPrimitiveMode;
  61945. /**
  61946. * Sets the primitive mode of the glTF mesh primitive
  61947. * @param meshPrimitive glTF mesh primitive
  61948. * @param primitiveMode The primitive mode
  61949. */
  61950. private setPrimitiveMode;
  61951. /**
  61952. * Sets the vertex attribute accessor based of the glTF mesh primitive
  61953. * @param meshPrimitive glTF mesh primitive
  61954. * @param attributeKind vertex attribute
  61955. * @returns boolean specifying if uv coordinates are present
  61956. */
  61957. private setAttributeKind;
  61958. /**
  61959. * Sets data for the primitive attributes of each submesh
  61960. * @param mesh glTF Mesh object to store the primitive attribute information
  61961. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  61962. * @param binaryWriter Buffer to write the attribute data to
  61963. */
  61964. private setPrimitiveAttributesAsync;
  61965. /**
  61966. * Creates a glTF scene based on the array of meshes
  61967. * Returns the the total byte offset
  61968. * @param babylonScene Babylon scene to get the mesh data from
  61969. * @param binaryWriter Buffer to write binary data to
  61970. */
  61971. private createSceneAsync;
  61972. /**
  61973. * Creates a mapping of Node unique id to node index and handles animations
  61974. * @param babylonScene Babylon Scene
  61975. * @param nodes Babylon transform nodes
  61976. * @param shouldExportNode Callback specifying if a transform node should be exported
  61977. * @param binaryWriter Buffer to write binary data to
  61978. * @returns Node mapping of unique id to index
  61979. */
  61980. private createNodeMapAndAnimationsAsync;
  61981. /**
  61982. * Creates a glTF node from a Babylon mesh
  61983. * @param babylonMesh Source Babylon mesh
  61984. * @param binaryWriter Buffer for storing geometry data
  61985. * @returns glTF node
  61986. */
  61987. private createNodeAsync;
  61988. }
  61989. /**
  61990. * @hidden
  61991. *
  61992. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  61993. */
  61994. export class _BinaryWriter {
  61995. /**
  61996. * Array buffer which stores all binary data
  61997. */
  61998. private _arrayBuffer;
  61999. /**
  62000. * View of the array buffer
  62001. */
  62002. private _dataView;
  62003. /**
  62004. * byte offset of data in array buffer
  62005. */
  62006. private _byteOffset;
  62007. /**
  62008. * Initialize binary writer with an initial byte length
  62009. * @param byteLength Initial byte length of the array buffer
  62010. */
  62011. constructor(byteLength: number);
  62012. /**
  62013. * Resize the array buffer to the specified byte length
  62014. * @param byteLength
  62015. */
  62016. private resizeBuffer;
  62017. /**
  62018. * Get an array buffer with the length of the byte offset
  62019. * @returns ArrayBuffer resized to the byte offset
  62020. */
  62021. getArrayBuffer(): ArrayBuffer;
  62022. /**
  62023. * Get the byte offset of the array buffer
  62024. * @returns byte offset
  62025. */
  62026. getByteOffset(): number;
  62027. /**
  62028. * Stores an UInt8 in the array buffer
  62029. * @param entry
  62030. * @param byteOffset If defined, specifies where to set the value as an offset.
  62031. */
  62032. setUInt8(entry: number, byteOffset?: number): void;
  62033. /**
  62034. * Gets an UInt32 in the array buffer
  62035. * @param entry
  62036. * @param byteOffset If defined, specifies where to set the value as an offset.
  62037. */
  62038. getUInt32(byteOffset: number): number;
  62039. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  62040. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  62041. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  62042. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  62043. /**
  62044. * Stores a Float32 in the array buffer
  62045. * @param entry
  62046. */
  62047. setFloat32(entry: number, byteOffset?: number): void;
  62048. /**
  62049. * Stores an UInt32 in the array buffer
  62050. * @param entry
  62051. * @param byteOffset If defined, specifies where to set the value as an offset.
  62052. */
  62053. setUInt32(entry: number, byteOffset?: number): void;
  62054. }
  62055. }
  62056. declare module BABYLON.GLTF2.Exporter {
  62057. /**
  62058. * @hidden
  62059. * Interface to store animation data.
  62060. */
  62061. export interface _IAnimationData {
  62062. /**
  62063. * Keyframe data.
  62064. */
  62065. inputs: number[];
  62066. /**
  62067. * Value data.
  62068. */
  62069. outputs: number[][];
  62070. /**
  62071. * Animation interpolation data.
  62072. */
  62073. samplerInterpolation: AnimationSamplerInterpolation;
  62074. /**
  62075. * Minimum keyframe value.
  62076. */
  62077. inputsMin: number;
  62078. /**
  62079. * Maximum keyframe value.
  62080. */
  62081. inputsMax: number;
  62082. }
  62083. /**
  62084. * @hidden
  62085. */
  62086. export interface _IAnimationInfo {
  62087. /**
  62088. * The target channel for the animation
  62089. */
  62090. animationChannelTargetPath: AnimationChannelTargetPath;
  62091. /**
  62092. * The glTF accessor type for the data.
  62093. */
  62094. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  62095. /**
  62096. * Specifies if quaternions should be used.
  62097. */
  62098. useQuaternion: boolean;
  62099. }
  62100. /**
  62101. * @hidden
  62102. * Utility class for generating glTF animation data from BabylonJS.
  62103. */
  62104. export class _GLTFAnimation {
  62105. /**
  62106. * @ignore
  62107. *
  62108. * Creates glTF channel animation from BabylonJS animation.
  62109. * @param babylonTransformNode - BabylonJS mesh.
  62110. * @param animation - animation.
  62111. * @param animationChannelTargetPath - The target animation channel.
  62112. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  62113. * @param useQuaternion - Specifies if quaternions are used.
  62114. * @returns nullable IAnimationData
  62115. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  62116. private static _DeduceAnimationInfo;
  62117. /**
  62118. * @ignore
  62119. * Create node animations from the transform node animations
  62120. * @param babylonNode
  62121. * @param runtimeGLTFAnimation
  62122. * @param idleGLTFAnimations
  62123. * @param nodeMap
  62124. * @param nodes
  62125. * @param binaryWriter
  62126. * @param bufferViews
  62127. * @param accessors
  62128. * @param convertToRightHandedSystem
  62129. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  62130. [key: number]: number;
  62131. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  62132. /**
  62133. * @ignore
  62134. * Create node animations from the animation groups
  62135. * @param babylonScene
  62136. * @param glTFAnimations
  62137. * @param nodeMap
  62138. * @param nodes
  62139. * @param binaryWriter
  62140. * @param bufferViews
  62141. * @param accessors
  62142. * @param convertToRightHandedSystem
  62143. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  62144. [key: number]: number;
  62145. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  62146. private static AddAnimation;
  62147. /**
  62148. * Create a baked animation
  62149. * @param babylonTransformNode BabylonJS mesh
  62150. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  62151. * @param animationChannelTargetPath animation target channel
  62152. * @param minFrame minimum animation frame
  62153. * @param maxFrame maximum animation frame
  62154. * @param fps frames per second of the animation
  62155. * @param inputs input key frames of the animation
  62156. * @param outputs output key frame data of the animation
  62157. * @param convertToRightHandedSystem converts the values to right-handed
  62158. * @param useQuaternion specifies if quaternions should be used
  62159. */
  62160. private static _CreateBakedAnimation;
  62161. private static _ConvertFactorToVector3OrQuaternion;
  62162. private static _SetInterpolatedValue;
  62163. /**
  62164. * Creates linear animation from the animation key frames
  62165. * @param babylonTransformNode BabylonJS mesh
  62166. * @param animation BabylonJS animation
  62167. * @param animationChannelTargetPath The target animation channel
  62168. * @param frameDelta The difference between the last and first frame of the animation
  62169. * @param inputs Array to store the key frame times
  62170. * @param outputs Array to store the key frame data
  62171. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  62172. * @param useQuaternion Specifies if quaternions are used in the animation
  62173. */
  62174. private static _CreateLinearOrStepAnimation;
  62175. /**
  62176. * Creates cubic spline animation from the animation key frames
  62177. * @param babylonTransformNode BabylonJS mesh
  62178. * @param animation BabylonJS animation
  62179. * @param animationChannelTargetPath The target animation channel
  62180. * @param frameDelta The difference between the last and first frame of the animation
  62181. * @param inputs Array to store the key frame times
  62182. * @param outputs Array to store the key frame data
  62183. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  62184. * @param useQuaternion Specifies if quaternions are used in the animation
  62185. */
  62186. private static _CreateCubicSplineAnimation;
  62187. private static _GetBasePositionRotationOrScale;
  62188. /**
  62189. * Adds a key frame value
  62190. * @param keyFrame
  62191. * @param animation
  62192. * @param outputs
  62193. * @param animationChannelTargetPath
  62194. * @param basePositionRotationOrScale
  62195. * @param convertToRightHandedSystem
  62196. * @param useQuaternion
  62197. */
  62198. private static _AddKeyframeValue;
  62199. /**
  62200. * Determine the interpolation based on the key frames
  62201. * @param keyFrames
  62202. * @param animationChannelTargetPath
  62203. * @param useQuaternion
  62204. */
  62205. private static _DeduceInterpolation;
  62206. /**
  62207. * Adds an input tangent or output tangent to the output data
  62208. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  62209. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  62210. * @param outputs The animation data by keyframe
  62211. * @param animationChannelTargetPath The target animation channel
  62212. * @param interpolation The interpolation type
  62213. * @param keyFrame The key frame with the animation data
  62214. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  62215. * @param useQuaternion Specifies if quaternions are used
  62216. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  62217. */
  62218. private static AddSplineTangent;
  62219. /**
  62220. * Get the minimum and maximum key frames' frame values
  62221. * @param keyFrames animation key frames
  62222. * @returns the minimum and maximum key frame value
  62223. */
  62224. private static calculateMinMaxKeyFrames;
  62225. }
  62226. }
  62227. declare module BABYLON.GLTF2.Exporter {
  62228. /** @hidden */
  62229. export var textureTransformPixelShader: {
  62230. name: string;
  62231. shader: string;
  62232. };
  62233. }
  62234. declare module BABYLON.GLTF2.Exporter.Extensions {
  62235. /**
  62236. * @hidden
  62237. */
  62238. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  62239. /** Name of this extension */
  62240. readonly name: string;
  62241. /** Defines whether this extension is enabled */
  62242. enabled: boolean;
  62243. /** Defines whether this extension is required */
  62244. required: boolean;
  62245. /** Reference to the glTF exporter */
  62246. private _exporter;
  62247. constructor(exporter: _Exporter);
  62248. dispose(): void;
  62249. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  62250. /**
  62251. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  62252. * @param babylonTexture
  62253. * @param offset
  62254. * @param rotation
  62255. * @param scale
  62256. * @param scene
  62257. */
  62258. textureTransformTextureAsync(babylonTexture: Texture, offset: Vector2, rotation: number, scale: Vector2, scene: Scene): Promise<BaseTexture>;
  62259. }
  62260. }
  62261. declare module BABYLON.GLTF2.Exporter.Extensions {
  62262. /**
  62263. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  62264. */
  62265. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  62266. /** The name of this extension. */
  62267. readonly name: string;
  62268. /** Defines whether this extension is enabled. */
  62269. enabled: boolean;
  62270. /** Defines whether this extension is required */
  62271. required: boolean;
  62272. /** Reference to the glTF exporter */
  62273. private _exporter;
  62274. private _lights;
  62275. /** @hidden */
  62276. constructor(exporter: _Exporter);
  62277. /** @hidden */
  62278. dispose(): void;
  62279. /** @hidden */
  62280. onExporting(): void;
  62281. /**
  62282. * Define this method to modify the default behavior when exporting a node
  62283. * @param context The context when exporting the node
  62284. * @param node glTF node
  62285. * @param babylonNode BabylonJS node
  62286. * @returns nullable INode promise
  62287. */
  62288. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  62289. }
  62290. }
  62291. declare module BABYLON {
  62292. /**
  62293. * Class for generating STL data from a Babylon scene.
  62294. */
  62295. export class STLExport {
  62296. /**
  62297. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  62298. * @param meshes list defines the mesh to serialize
  62299. * @param download triggers the automatic download of the file.
  62300. * @param fileName changes the downloads fileName.
  62301. * @param binary changes the STL to a binary type.
  62302. * @param isLittleEndian toggle for binary type exporter.
  62303. * @returns the STL as UTF8 string
  62304. */
  62305. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  62306. }
  62307. }
  62308. /**
  62309. * @ignoreChildren
  62310. * @ignore
  62311. */
  62312. declare module "babylonjs-gltf2interface" {
  62313. export = BABYLON.GLTF2;
  62314. }
  62315. /**
  62316. * Module for glTF 2.0 Interface
  62317. * @ignoreChildren
  62318. * @ignore
  62319. */
  62320. declare module BABYLON.GLTF2 {
  62321. /**
  62322. * The datatype of the components in the attribute
  62323. */
  62324. const enum AccessorComponentType {
  62325. /**
  62326. * Byte
  62327. */
  62328. BYTE = 5120,
  62329. /**
  62330. * Unsigned Byte
  62331. */
  62332. UNSIGNED_BYTE = 5121,
  62333. /**
  62334. * Short
  62335. */
  62336. SHORT = 5122,
  62337. /**
  62338. * Unsigned Short
  62339. */
  62340. UNSIGNED_SHORT = 5123,
  62341. /**
  62342. * Unsigned Int
  62343. */
  62344. UNSIGNED_INT = 5125,
  62345. /**
  62346. * Float
  62347. */
  62348. FLOAT = 5126,
  62349. }
  62350. /**
  62351. * Specifies if the attirbute is a scalar, vector, or matrix
  62352. */
  62353. const enum AccessorType {
  62354. /**
  62355. * Scalar
  62356. */
  62357. SCALAR = "SCALAR",
  62358. /**
  62359. * Vector2
  62360. */
  62361. VEC2 = "VEC2",
  62362. /**
  62363. * Vector3
  62364. */
  62365. VEC3 = "VEC3",
  62366. /**
  62367. * Vector4
  62368. */
  62369. VEC4 = "VEC4",
  62370. /**
  62371. * Matrix2x2
  62372. */
  62373. MAT2 = "MAT2",
  62374. /**
  62375. * Matrix3x3
  62376. */
  62377. MAT3 = "MAT3",
  62378. /**
  62379. * Matrix4x4
  62380. */
  62381. MAT4 = "MAT4",
  62382. }
  62383. /**
  62384. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  62385. */
  62386. const enum AnimationChannelTargetPath {
  62387. /**
  62388. * Translation
  62389. */
  62390. TRANSLATION = "translation",
  62391. /**
  62392. * Rotation
  62393. */
  62394. ROTATION = "rotation",
  62395. /**
  62396. * Scale
  62397. */
  62398. SCALE = "scale",
  62399. /**
  62400. * Weights
  62401. */
  62402. WEIGHTS = "weights",
  62403. }
  62404. /**
  62405. * Interpolation algorithm
  62406. */
  62407. const enum AnimationSamplerInterpolation {
  62408. /**
  62409. * The animated values are linearly interpolated between keyframes
  62410. */
  62411. LINEAR = "LINEAR",
  62412. /**
  62413. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  62414. */
  62415. STEP = "STEP",
  62416. /**
  62417. * The animation's interpolation is computed using a cubic spline with specified tangents
  62418. */
  62419. CUBICSPLINE = "CUBICSPLINE",
  62420. }
  62421. /**
  62422. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  62423. */
  62424. const enum CameraType {
  62425. /**
  62426. * A perspective camera containing properties to create a perspective projection matrix
  62427. */
  62428. PERSPECTIVE = "perspective",
  62429. /**
  62430. * An orthographic camera containing properties to create an orthographic projection matrix
  62431. */
  62432. ORTHOGRAPHIC = "orthographic",
  62433. }
  62434. /**
  62435. * The mime-type of the image
  62436. */
  62437. const enum ImageMimeType {
  62438. /**
  62439. * JPEG Mime-type
  62440. */
  62441. JPEG = "image/jpeg",
  62442. /**
  62443. * PNG Mime-type
  62444. */
  62445. PNG = "image/png",
  62446. }
  62447. /**
  62448. * The alpha rendering mode of the material
  62449. */
  62450. const enum MaterialAlphaMode {
  62451. /**
  62452. * The alpha value is ignored and the rendered output is fully opaque
  62453. */
  62454. OPAQUE = "OPAQUE",
  62455. /**
  62456. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  62457. */
  62458. MASK = "MASK",
  62459. /**
  62460. * The alpha value is used to composite the source and destination areas. The rendered output is combined with the background using the normal painting operation (i.e. the Porter and Duff over operator)
  62461. */
  62462. BLEND = "BLEND",
  62463. }
  62464. /**
  62465. * The type of the primitives to render
  62466. */
  62467. const enum MeshPrimitiveMode {
  62468. /**
  62469. * Points
  62470. */
  62471. POINTS = 0,
  62472. /**
  62473. * Lines
  62474. */
  62475. LINES = 1,
  62476. /**
  62477. * Line Loop
  62478. */
  62479. LINE_LOOP = 2,
  62480. /**
  62481. * Line Strip
  62482. */
  62483. LINE_STRIP = 3,
  62484. /**
  62485. * Triangles
  62486. */
  62487. TRIANGLES = 4,
  62488. /**
  62489. * Triangle Strip
  62490. */
  62491. TRIANGLE_STRIP = 5,
  62492. /**
  62493. * Triangle Fan
  62494. */
  62495. TRIANGLE_FAN = 6,
  62496. }
  62497. /**
  62498. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  62499. */
  62500. const enum TextureMagFilter {
  62501. /**
  62502. * Nearest
  62503. */
  62504. NEAREST = 9728,
  62505. /**
  62506. * Linear
  62507. */
  62508. LINEAR = 9729,
  62509. }
  62510. /**
  62511. * Minification filter. All valid values correspond to WebGL enums
  62512. */
  62513. const enum TextureMinFilter {
  62514. /**
  62515. * Nearest
  62516. */
  62517. NEAREST = 9728,
  62518. /**
  62519. * Linear
  62520. */
  62521. LINEAR = 9729,
  62522. /**
  62523. * Nearest Mip-Map Nearest
  62524. */
  62525. NEAREST_MIPMAP_NEAREST = 9984,
  62526. /**
  62527. * Linear Mipmap Nearest
  62528. */
  62529. LINEAR_MIPMAP_NEAREST = 9985,
  62530. /**
  62531. * Nearest Mipmap Linear
  62532. */
  62533. NEAREST_MIPMAP_LINEAR = 9986,
  62534. /**
  62535. * Linear Mipmap Linear
  62536. */
  62537. LINEAR_MIPMAP_LINEAR = 9987,
  62538. }
  62539. /**
  62540. * S (U) wrapping mode. All valid values correspond to WebGL enums
  62541. */
  62542. const enum TextureWrapMode {
  62543. /**
  62544. * Clamp to Edge
  62545. */
  62546. CLAMP_TO_EDGE = 33071,
  62547. /**
  62548. * Mirrored Repeat
  62549. */
  62550. MIRRORED_REPEAT = 33648,
  62551. /**
  62552. * Repeat
  62553. */
  62554. REPEAT = 10497,
  62555. }
  62556. /**
  62557. * glTF Property
  62558. */
  62559. interface IProperty {
  62560. /**
  62561. * Dictionary object with extension-specific objects
  62562. */
  62563. extensions?: {
  62564. [key: string]: any;
  62565. };
  62566. /**
  62567. * Application-Specific data
  62568. */
  62569. extras?: any;
  62570. }
  62571. /**
  62572. * glTF Child of Root Property
  62573. */
  62574. interface IChildRootProperty extends IProperty {
  62575. /**
  62576. * The user-defined name of this object
  62577. */
  62578. name?: string;
  62579. }
  62580. /**
  62581. * Indices of those attributes that deviate from their initialization value
  62582. */
  62583. interface IAccessorSparseIndices extends IProperty {
  62584. /**
  62585. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  62586. */
  62587. bufferView: number;
  62588. /**
  62589. * The offset relative to the start of the bufferView in bytes. Must be aligned
  62590. */
  62591. byteOffset?: number;
  62592. /**
  62593. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  62594. */
  62595. componentType: AccessorComponentType;
  62596. }
  62597. /**
  62598. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  62599. */
  62600. interface IAccessorSparseValues extends IProperty {
  62601. /**
  62602. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  62603. */
  62604. bufferView: number;
  62605. /**
  62606. * The offset relative to the start of the bufferView in bytes. Must be aligned
  62607. */
  62608. byteOffset?: number;
  62609. }
  62610. /**
  62611. * Sparse storage of attributes that deviate from their initialization value
  62612. */
  62613. interface IAccessorSparse extends IProperty {
  62614. /**
  62615. * The number of attributes encoded in this sparse accessor
  62616. */
  62617. count: number;
  62618. /**
  62619. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  62620. */
  62621. indices: IAccessorSparseIndices;
  62622. /**
  62623. * Array of size count times number of components, storing the displaced accessor attributes pointed by indices. Substituted values must have the same componentType and number of components as the base accessor
  62624. */
  62625. values: IAccessorSparseValues;
  62626. }
  62627. /**
  62628. * A typed view into a bufferView. A bufferView contains raw binary data. An accessor provides a typed view into a bufferView or a subset of a bufferView similar to how WebGL's vertexAttribPointer() defines an attribute in a buffer
  62629. */
  62630. interface IAccessor extends IChildRootProperty {
  62631. /**
  62632. * The index of the bufferview
  62633. */
  62634. bufferView?: number;
  62635. /**
  62636. * The offset relative to the start of the bufferView in bytes
  62637. */
  62638. byteOffset?: number;
  62639. /**
  62640. * The datatype of components in the attribute
  62641. */
  62642. componentType: AccessorComponentType;
  62643. /**
  62644. * Specifies whether integer data values should be normalized
  62645. */
  62646. normalized?: boolean;
  62647. /**
  62648. * The number of attributes referenced by this accessor
  62649. */
  62650. count: number;
  62651. /**
  62652. * Specifies if the attribute is a scalar, vector, or matrix
  62653. */
  62654. type: AccessorType;
  62655. /**
  62656. * Maximum value of each component in this attribute
  62657. */
  62658. max?: number[];
  62659. /**
  62660. * Minimum value of each component in this attribute
  62661. */
  62662. min?: number[];
  62663. /**
  62664. * Sparse storage of attributes that deviate from their initialization value
  62665. */
  62666. sparse?: IAccessorSparse;
  62667. }
  62668. /**
  62669. * Targets an animation's sampler at a node's property
  62670. */
  62671. interface IAnimationChannel extends IProperty {
  62672. /**
  62673. * The index of a sampler in this animation used to compute the value for the target
  62674. */
  62675. sampler: number;
  62676. /**
  62677. * The index of the node and TRS property to target
  62678. */
  62679. target: IAnimationChannelTarget;
  62680. }
  62681. /**
  62682. * The index of the node and TRS property that an animation channel targets
  62683. */
  62684. interface IAnimationChannelTarget extends IProperty {
  62685. /**
  62686. * The index of the node to target
  62687. */
  62688. node: number;
  62689. /**
  62690. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  62691. */
  62692. path: AnimationChannelTargetPath;
  62693. }
  62694. /**
  62695. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  62696. */
  62697. interface IAnimationSampler extends IProperty {
  62698. /**
  62699. * The index of an accessor containing keyframe input values, e.g., time
  62700. */
  62701. input: number;
  62702. /**
  62703. * Interpolation algorithm
  62704. */
  62705. interpolation?: AnimationSamplerInterpolation;
  62706. /**
  62707. * The index of an accessor, containing keyframe output values
  62708. */
  62709. output: number;
  62710. }
  62711. /**
  62712. * A keyframe animation
  62713. */
  62714. interface IAnimation extends IChildRootProperty {
  62715. /**
  62716. * An array of channels, each of which targets an animation's sampler at a node's property
  62717. */
  62718. channels: IAnimationChannel[];
  62719. /**
  62720. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  62721. */
  62722. samplers: IAnimationSampler[];
  62723. }
  62724. /**
  62725. * Metadata about the glTF asset
  62726. */
  62727. interface IAsset extends IChildRootProperty {
  62728. /**
  62729. * A copyright message suitable for display to credit the content creator
  62730. */
  62731. copyright?: string;
  62732. /**
  62733. * Tool that generated this glTF model. Useful for debugging
  62734. */
  62735. generator?: string;
  62736. /**
  62737. * The glTF version that this asset targets
  62738. */
  62739. version: string;
  62740. /**
  62741. * The minimum glTF version that this asset targets
  62742. */
  62743. minVersion?: string;
  62744. }
  62745. /**
  62746. * A buffer points to binary geometry, animation, or skins
  62747. */
  62748. interface IBuffer extends IChildRootProperty {
  62749. /**
  62750. * The uri of the buffer. Relative paths are relative to the .gltf file. Instead of referencing an external file, the uri can also be a data-uri
  62751. */
  62752. uri?: string;
  62753. /**
  62754. * The length of the buffer in bytes
  62755. */
  62756. byteLength: number;
  62757. }
  62758. /**
  62759. * A view into a buffer generally representing a subset of the buffer
  62760. */
  62761. interface IBufferView extends IChildRootProperty {
  62762. /**
  62763. * The index of the buffer
  62764. */
  62765. buffer: number;
  62766. /**
  62767. * The offset into the buffer in bytes
  62768. */
  62769. byteOffset?: number;
  62770. /**
  62771. * The lenth of the bufferView in bytes
  62772. */
  62773. byteLength: number;
  62774. /**
  62775. * The stride, in bytes
  62776. */
  62777. byteStride?: number;
  62778. }
  62779. /**
  62780. * An orthographic camera containing properties to create an orthographic projection matrix
  62781. */
  62782. interface ICameraOrthographic extends IProperty {
  62783. /**
  62784. * The floating-point horizontal magnification of the view. Must not be zero
  62785. */
  62786. xmag: number;
  62787. /**
  62788. * The floating-point vertical magnification of the view. Must not be zero
  62789. */
  62790. ymag: number;
  62791. /**
  62792. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  62793. */
  62794. zfar: number;
  62795. /**
  62796. * The floating-point distance to the near clipping plane
  62797. */
  62798. znear: number;
  62799. }
  62800. /**
  62801. * A perspective camera containing properties to create a perspective projection matrix
  62802. */
  62803. interface ICameraPerspective extends IProperty {
  62804. /**
  62805. * The floating-point aspect ratio of the field of view
  62806. */
  62807. aspectRatio?: number;
  62808. /**
  62809. * The floating-point vertical field of view in radians
  62810. */
  62811. yfov: number;
  62812. /**
  62813. * The floating-point distance to the far clipping plane
  62814. */
  62815. zfar?: number;
  62816. /**
  62817. * The floating-point distance to the near clipping plane
  62818. */
  62819. znear: number;
  62820. }
  62821. /**
  62822. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  62823. */
  62824. interface ICamera extends IChildRootProperty {
  62825. /**
  62826. * An orthographic camera containing properties to create an orthographic projection matrix
  62827. */
  62828. orthographic?: ICameraOrthographic;
  62829. /**
  62830. * A perspective camera containing properties to create a perspective projection matrix
  62831. */
  62832. perspective?: ICameraPerspective;
  62833. /**
  62834. * Specifies if the camera uses a perspective or orthographic projection
  62835. */
  62836. type: CameraType;
  62837. }
  62838. /**
  62839. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  62840. */
  62841. interface IImage extends IChildRootProperty {
  62842. /**
  62843. * The uri of the image. Relative paths are relative to the .gltf file. Instead of referencing an external file, the uri can also be a data-uri. The image format must be jpg or png
  62844. */
  62845. uri?: string;
  62846. /**
  62847. * The image's MIME type
  62848. */
  62849. mimeType?: ImageMimeType;
  62850. /**
  62851. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  62852. */
  62853. bufferView?: number;
  62854. }
  62855. /**
  62856. * Material Normal Texture Info
  62857. */
  62858. interface IMaterialNormalTextureInfo extends ITextureInfo {
  62859. /**
  62860. * The scalar multiplier applied to each normal vector of the normal texture
  62861. */
  62862. scale?: number;
  62863. }
  62864. /**
  62865. * Material Occlusion Texture Info
  62866. */
  62867. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  62868. /**
  62869. * A scalar multiplier controlling the amount of occlusion applied
  62870. */
  62871. strength?: number;
  62872. }
  62873. /**
  62874. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  62875. */
  62876. interface IMaterialPbrMetallicRoughness {
  62877. /**
  62878. * The material's base color factor
  62879. */
  62880. baseColorFactor?: number[];
  62881. /**
  62882. * The base color texture
  62883. */
  62884. baseColorTexture?: ITextureInfo;
  62885. /**
  62886. * The metalness of the material
  62887. */
  62888. metallicFactor?: number;
  62889. /**
  62890. * The roughness of the material
  62891. */
  62892. roughnessFactor?: number;
  62893. /**
  62894. * The metallic-roughness texture
  62895. */
  62896. metallicRoughnessTexture?: ITextureInfo;
  62897. }
  62898. /**
  62899. * The material appearance of a primitive
  62900. */
  62901. interface IMaterial extends IChildRootProperty {
  62902. /**
  62903. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology. When not specified, all the default values of pbrMetallicRoughness apply
  62904. */
  62905. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  62906. /**
  62907. * The normal map texture
  62908. */
  62909. normalTexture?: IMaterialNormalTextureInfo;
  62910. /**
  62911. * The occlusion map texture
  62912. */
  62913. occlusionTexture?: IMaterialOcclusionTextureInfo;
  62914. /**
  62915. * The emissive map texture
  62916. */
  62917. emissiveTexture?: ITextureInfo;
  62918. /**
  62919. * The RGB components of the emissive color of the material. These values are linear. If an emissiveTexture is specified, this value is multiplied with the texel values
  62920. */
  62921. emissiveFactor?: number[];
  62922. /**
  62923. * The alpha rendering mode of the material
  62924. */
  62925. alphaMode?: MaterialAlphaMode;
  62926. /**
  62927. * The alpha cutoff value of the material
  62928. */
  62929. alphaCutoff?: number;
  62930. /**
  62931. * Specifies whether the material is double sided
  62932. */
  62933. doubleSided?: boolean;
  62934. }
  62935. /**
  62936. * Geometry to be rendered with the given material
  62937. */
  62938. interface IMeshPrimitive extends IProperty {
  62939. /**
  62940. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  62941. */
  62942. attributes: {
  62943. [name: string]: number;
  62944. };
  62945. /**
  62946. * The index of the accessor that contains the indices
  62947. */
  62948. indices?: number;
  62949. /**
  62950. * The index of the material to apply to this primitive when rendering
  62951. */
  62952. material?: number;
  62953. /**
  62954. * The type of primitives to render. All valid values correspond to WebGL enums
  62955. */
  62956. mode?: MeshPrimitiveMode;
  62957. /**
  62958. * An array of Morph Targets, each Morph Target is a dictionary mapping attributes (only POSITION, NORMAL, and TANGENT supported) to their deviations in the Morph Target
  62959. */
  62960. targets?: {
  62961. [name: string]: number;
  62962. }[];
  62963. }
  62964. /**
  62965. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  62966. */
  62967. interface IMesh extends IChildRootProperty {
  62968. /**
  62969. * An array of primitives, each defining geometry to be rendered with a material
  62970. */
  62971. primitives: IMeshPrimitive[];
  62972. /**
  62973. * Array of weights to be applied to the Morph Targets
  62974. */
  62975. weights?: number[];
  62976. }
  62977. /**
  62978. * A node in the node hierarchy
  62979. */
  62980. interface INode extends IChildRootProperty {
  62981. /**
  62982. * The index of the camera referenced by this node
  62983. */
  62984. camera?: number;
  62985. /**
  62986. * The indices of this node's children
  62987. */
  62988. children?: number[];
  62989. /**
  62990. * The index of the skin referenced by this node
  62991. */
  62992. skin?: number;
  62993. /**
  62994. * A floating-point 4x4 transformation matrix stored in column-major order
  62995. */
  62996. matrix?: number[];
  62997. /**
  62998. * The index of the mesh in this node
  62999. */
  63000. mesh?: number;
  63001. /**
  63002. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  63003. */
  63004. rotation?: number[];
  63005. /**
  63006. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  63007. */
  63008. scale?: number[];
  63009. /**
  63010. * The node's translation along the x, y, and z axes
  63011. */
  63012. translation?: number[];
  63013. /**
  63014. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  63015. */
  63016. weights?: number[];
  63017. }
  63018. /**
  63019. * Texture sampler properties for filtering and wrapping modes
  63020. */
  63021. interface ISampler extends IChildRootProperty {
  63022. /**
  63023. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  63024. */
  63025. magFilter?: TextureMagFilter;
  63026. /**
  63027. * Minification filter. All valid values correspond to WebGL enums
  63028. */
  63029. minFilter?: TextureMinFilter;
  63030. /**
  63031. * S (U) wrapping mode. All valid values correspond to WebGL enums
  63032. */
  63033. wrapS?: TextureWrapMode;
  63034. /**
  63035. * T (V) wrapping mode. All valid values correspond to WebGL enums
  63036. */
  63037. wrapT?: TextureWrapMode;
  63038. }
  63039. /**
  63040. * The root nodes of a scene
  63041. */
  63042. interface IScene extends IChildRootProperty {
  63043. /**
  63044. * The indices of each root node
  63045. */
  63046. nodes: number[];
  63047. }
  63048. /**
  63049. * Joints and matrices defining a skin
  63050. */
  63051. interface ISkin extends IChildRootProperty {
  63052. /**
  63053. * The index of the accessor containing the floating-point 4x4 inverse-bind matrices. The default is that each matrix is a 4x4 identity matrix, which implies that inverse-bind matrices were pre-applied
  63054. */
  63055. inverseBindMatrices?: number;
  63056. /**
  63057. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  63058. */
  63059. skeleton?: number;
  63060. /**
  63061. * Indices of skeleton nodes, used as joints in this skin. The array length must be the same as the count property of the inverseBindMatrices accessor (when defined)
  63062. */
  63063. joints: number[];
  63064. }
  63065. /**
  63066. * A texture and its sampler
  63067. */
  63068. interface ITexture extends IChildRootProperty {
  63069. /**
  63070. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  63071. */
  63072. sampler?: number;
  63073. /**
  63074. * The index of the image used by this texture
  63075. */
  63076. source: number;
  63077. }
  63078. /**
  63079. * Reference to a texture
  63080. */
  63081. interface ITextureInfo extends IProperty {
  63082. /**
  63083. * The index of the texture
  63084. */
  63085. index: number;
  63086. /**
  63087. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  63088. */
  63089. texCoord?: number;
  63090. }
  63091. /**
  63092. * The root object for a glTF asset
  63093. */
  63094. interface IGLTF extends IProperty {
  63095. /**
  63096. * An array of accessors. An accessor is a typed view into a bufferView
  63097. */
  63098. accessors?: IAccessor[];
  63099. /**
  63100. * An array of keyframe animations
  63101. */
  63102. animations?: IAnimation[];
  63103. /**
  63104. * Metadata about the glTF asset
  63105. */
  63106. asset: IAsset;
  63107. /**
  63108. * An array of buffers. A buffer points to binary geometry, animation, or skins
  63109. */
  63110. buffers?: IBuffer[];
  63111. /**
  63112. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  63113. */
  63114. bufferViews?: IBufferView[];
  63115. /**
  63116. * An array of cameras
  63117. */
  63118. cameras?: ICamera[];
  63119. /**
  63120. * Names of glTF extensions used somewhere in this asset
  63121. */
  63122. extensionsUsed?: string[];
  63123. /**
  63124. * Names of glTF extensions required to properly load this asset
  63125. */
  63126. extensionsRequired?: string[];
  63127. /**
  63128. * An array of images. An image defines data used to create a texture
  63129. */
  63130. images?: IImage[];
  63131. /**
  63132. * An array of materials. A material defines the appearance of a primitive
  63133. */
  63134. materials?: IMaterial[];
  63135. /**
  63136. * An array of meshes. A mesh is a set of primitives to be rendered
  63137. */
  63138. meshes?: IMesh[];
  63139. /**
  63140. * An array of nodes
  63141. */
  63142. nodes?: INode[];
  63143. /**
  63144. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  63145. */
  63146. samplers?: ISampler[];
  63147. /**
  63148. * The index of the default scene
  63149. */
  63150. scene?: number;
  63151. /**
  63152. * An array of scenes
  63153. */
  63154. scenes?: IScene[];
  63155. /**
  63156. * An array of skins. A skin is defined by joints and matrices
  63157. */
  63158. skins?: ISkin[];
  63159. /**
  63160. * An array of textures
  63161. */
  63162. textures?: ITexture[];
  63163. }
  63164. /**
  63165. * Interface for glTF validation results
  63166. */
  63167. interface IGLTFValidationResults {
  63168. info: {
  63169. generator: string;
  63170. hasAnimations: boolean;
  63171. hasDefaultScene: boolean;
  63172. hasMaterials: boolean;
  63173. hasMorphTargets: boolean;
  63174. hasSkins: boolean;
  63175. hasTextures: boolean;
  63176. maxAttributesUsed: number;
  63177. primitivesCount: number
  63178. };
  63179. issues: {
  63180. messages: Array<string>;
  63181. numErrors: number;
  63182. numHints: number;
  63183. numInfos: number;
  63184. numWarnings: number;
  63185. truncated: boolean
  63186. };
  63187. mimeType: string;
  63188. uri: string;
  63189. validatedAt: string;
  63190. validatorVersion: string;
  63191. }
  63192. /**
  63193. * Interface for glTF validation options
  63194. */
  63195. interface IGLTFValidationOptions {
  63196. uri?: string;
  63197. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  63198. validateAccessorData?: boolean;
  63199. maxIssues?: number;
  63200. ignoredIssues?: Array<string>;
  63201. severityOverrides?: Object;
  63202. }
  63203. /**
  63204. * glTF validator object Tyyings
  63205. */
  63206. interface IGLTFValidatorTypings {
  63207. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  63208. }
  63209. }
  63210. /**
  63211. * Interface for glTF validation results
  63212. */
  63213. interface IGLTFValidationResults {
  63214. info: {
  63215. generator: string;
  63216. hasAnimations: boolean;
  63217. hasDefaultScene: boolean;
  63218. hasMaterials: boolean;
  63219. hasMorphTargets: boolean;
  63220. hasSkins: boolean;
  63221. hasTextures: boolean;
  63222. maxAttributesUsed: number;
  63223. primitivesCount: number
  63224. };
  63225. issues: {
  63226. messages: Array<string>;
  63227. numErrors: number;
  63228. numHints: number;
  63229. numInfos: number;
  63230. numWarnings: number;
  63231. truncated: boolean
  63232. };
  63233. mimeType: string;
  63234. uri: string;
  63235. validatedAt: string;
  63236. validatorVersion: string;
  63237. }
  63238. /**
  63239. * Interface for glTF validation options
  63240. */
  63241. interface IGLTFValidationOptions {
  63242. uri?: string;
  63243. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  63244. validateAccessorData?: boolean;
  63245. maxIssues?: number;
  63246. ignoredIssues?: Array<string>;
  63247. severityOverrides?: Object;
  63248. }
  63249. /**
  63250. * glTF validator object Tyyings
  63251. */
  63252. interface IGLTFValidatorTypings {
  63253. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  63254. }
  63255. declare module BABYLON {
  63256. /** @hidden */
  63257. export var cellPixelShader: {
  63258. name: string;
  63259. shader: string;
  63260. };
  63261. }
  63262. declare module BABYLON {
  63263. /** @hidden */
  63264. export var cellVertexShader: {
  63265. name: string;
  63266. shader: string;
  63267. };
  63268. }
  63269. declare module BABYLON {
  63270. export class CellMaterial extends BABYLON.PushMaterial {
  63271. private _diffuseTexture;
  63272. diffuseTexture: BABYLON.BaseTexture;
  63273. diffuseColor: BABYLON.Color3; computeHighLevel: boolean;
  63274. computeHighLevel: boolean;
  63275. private _disableLighting;
  63276. disableLighting: boolean;
  63277. private _maxSimultaneousLights;
  63278. maxSimultaneousLights: number;
  63279. private _renderId;
  63280. constructor(name: string, scene: BABYLON.Scene);
  63281. needAlphaBlending(): boolean;
  63282. needAlphaTesting(): boolean;
  63283. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63284. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63285. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63286. getAnimatables(): BABYLON.IAnimatable[];
  63287. getActiveTextures(): BABYLON.BaseTexture[];
  63288. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63289. dispose(forceDisposeEffect?: boolean): void;
  63290. getClassName(): string;
  63291. clone(name: string): CellMaterial;
  63292. serialize(): any;
  63293. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  63294. }
  63295. }
  63296. declare module BABYLON {
  63297. export class CustomShaderStructure {
  63298. FragmentStore: string;
  63299. VertexStore: string;
  63300. constructor();
  63301. }
  63302. export class ShaderSpecialParts {
  63303. constructor();
  63304. Fragment_Begin: string;
  63305. Fragment_Definitions: string;
  63306. Fragment_MainBegin: string;
  63307. Fragment_Custom_Diffuse: string;
  63308. Fragment_Before_Lights: string;
  63309. Fragment_Before_Fog: string;
  63310. Fragment_Custom_Alpha: string;
  63311. Fragment_Before_FragColor: string;
  63312. Vertex_Begin: string;
  63313. Vertex_Definitions: string;
  63314. Vertex_MainBegin: string;
  63315. Vertex_Before_PositionUpdated: string;
  63316. Vertex_Before_NormalUpdated: string;
  63317. Vertex_MainEnd: string;
  63318. }
  63319. export class CustomMaterial extends BABYLON.StandardMaterial {
  63320. static ShaderIndexer: number;
  63321. CustomParts: ShaderSpecialParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  63322. FragmentShader: string;
  63323. VertexShader: string;
  63324. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  63325. ReviewUniform(name: string, arr: string[]): string[];
  63326. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  63327. constructor(name: string, scene: BABYLON.Scene);
  63328. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  63329. Fragment_Begin(shaderPart: string): CustomMaterial;
  63330. Fragment_Definitions(shaderPart: string): CustomMaterial;
  63331. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  63332. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  63333. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  63334. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  63335. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  63336. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  63337. Vertex_Begin(shaderPart: string): CustomMaterial;
  63338. Vertex_Definitions(shaderPart: string): CustomMaterial;
  63339. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  63340. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  63341. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  63342. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  63343. }
  63344. }
  63345. declare module BABYLON {
  63346. export class ShaderAlebdoParts {
  63347. constructor();
  63348. Fragment_Begin: string;
  63349. Fragment_Definitions: string;
  63350. Fragment_MainBegin: string;
  63351. Fragment_Custom_Albedo: string;
  63352. Fragment_Before_Lights: string;
  63353. Fragment_Before_Fog: string;
  63354. Fragment_Custom_Alpha: string;
  63355. Fragment_Before_FragColor: string;
  63356. Vertex_Begin: string;
  63357. Vertex_Definitions: string;
  63358. Vertex_MainBegin: string;
  63359. Vertex_Before_PositionUpdated: string;
  63360. Vertex_Before_NormalUpdated: string;
  63361. Vertex_MainEnd: string;
  63362. }
  63363. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  63364. static ShaderIndexer: number;
  63365. CustomParts: ShaderAlebdoParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  63366. FragmentShader: string;
  63367. VertexShader: string;
  63368. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  63369. ReviewUniform(name: string, arr: string[]): string[];
  63370. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  63371. constructor(name: string, scene: BABYLON.Scene);
  63372. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  63373. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  63374. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  63375. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  63376. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  63377. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  63378. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  63379. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  63380. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  63381. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  63382. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  63383. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  63384. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  63385. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  63386. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  63387. }
  63388. }
  63389. declare module BABYLON {
  63390. /** @hidden */
  63391. export var firePixelShader: {
  63392. name: string;
  63393. shader: string;
  63394. };
  63395. }
  63396. declare module BABYLON {
  63397. /** @hidden */
  63398. export var fireVertexShader: {
  63399. name: string;
  63400. shader: string;
  63401. };
  63402. }
  63403. declare module BABYLON {
  63404. export class FireMaterial extends BABYLON.PushMaterial {
  63405. private _diffuseTexture;
  63406. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63407. private _distortionTexture;
  63408. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63409. private _opacityTexture;
  63410. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63411. diffuseColor: BABYLON.Color3;
  63412. speed: number;
  63413. private _scaledDiffuse;
  63414. private _renderId;
  63415. private _lastTime;
  63416. constructor(name: string, scene: BABYLON.Scene);
  63417. needAlphaBlending(): boolean;
  63418. needAlphaTesting(): boolean;
  63419. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63420. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63421. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63422. getAnimatables(): BABYLON.IAnimatable[];
  63423. getActiveTextures(): BABYLON.BaseTexture[];
  63424. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63425. getClassName(): string;
  63426. dispose(forceDisposeEffect?: boolean): void;
  63427. clone(name: string): FireMaterial;
  63428. serialize(): any;
  63429. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  63430. }
  63431. }
  63432. declare module BABYLON {
  63433. /** @hidden */
  63434. export var furPixelShader: {
  63435. name: string;
  63436. shader: string;
  63437. };
  63438. }
  63439. declare module BABYLON {
  63440. /** @hidden */
  63441. export var furVertexShader: {
  63442. name: string;
  63443. shader: string;
  63444. };
  63445. }
  63446. declare module BABYLON {
  63447. export class FurMaterial extends BABYLON.PushMaterial {
  63448. private _diffuseTexture;
  63449. diffuseTexture: BABYLON.BaseTexture;
  63450. private _heightTexture;
  63451. heightTexture: BABYLON.BaseTexture;
  63452. diffuseColor: BABYLON.Color3;
  63453. furLength: number;
  63454. furAngle: number;
  63455. furColor: BABYLON.Color3;
  63456. furOffset: number;
  63457. furSpacing: number;
  63458. furGravity: BABYLON.Vector3;
  63459. furSpeed: number;
  63460. furDensity: number;
  63461. furOcclusion: number;
  63462. furTexture: BABYLON.DynamicTexture;
  63463. private _disableLighting;
  63464. disableLighting: boolean;
  63465. private _maxSimultaneousLights;
  63466. maxSimultaneousLights: number;
  63467. highLevelFur: boolean; meshes: BABYLON.AbstractMesh[];
  63468. private _renderId;
  63469. private _furTime;
  63470. constructor(name: string, scene: BABYLON.Scene);
  63471. furTime: number;
  63472. needAlphaBlending(): boolean;
  63473. needAlphaTesting(): boolean;
  63474. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63475. updateFur(): void;
  63476. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63477. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63478. getAnimatables(): BABYLON.IAnimatable[];
  63479. getActiveTextures(): BABYLON.BaseTexture[];
  63480. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63481. dispose(forceDisposeEffect?: boolean): void;
  63482. clone(name: string): FurMaterial;
  63483. serialize(): any;
  63484. getClassName(): string;
  63485. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  63486. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  63487. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  63488. }
  63489. }
  63490. declare module BABYLON {
  63491. /** @hidden */
  63492. export var gradientPixelShader: {
  63493. name: string;
  63494. shader: string;
  63495. };
  63496. }
  63497. declare module BABYLON {
  63498. /** @hidden */
  63499. export var gradientVertexShader: {
  63500. name: string;
  63501. shader: string;
  63502. };
  63503. }
  63504. declare module BABYLON {
  63505. export class GradientMaterial extends BABYLON.PushMaterial {
  63506. private _maxSimultaneousLights;
  63507. maxSimultaneousLights: number;
  63508. topColor: BABYLON.Color3;
  63509. topColorAlpha: number;
  63510. bottomColor: BABYLON.Color3;
  63511. bottomColorAlpha: number;
  63512. offset: number;
  63513. scale: number;
  63514. smoothness: number;
  63515. private _disableLighting;
  63516. disableLighting: boolean;
  63517. private _renderId;
  63518. constructor(name: string, scene: BABYLON.Scene);
  63519. needAlphaBlending(): boolean;
  63520. needAlphaTesting(): boolean;
  63521. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63522. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63523. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63524. getAnimatables(): BABYLON.IAnimatable[];
  63525. dispose(forceDisposeEffect?: boolean): void;
  63526. clone(name: string): GradientMaterial;
  63527. serialize(): any;
  63528. getClassName(): string;
  63529. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  63530. }
  63531. }
  63532. declare module BABYLON {
  63533. /** @hidden */
  63534. export var gridPixelShader: {
  63535. name: string;
  63536. shader: string;
  63537. };
  63538. }
  63539. declare module BABYLON {
  63540. /** @hidden */
  63541. export var gridVertexShader: {
  63542. name: string;
  63543. shader: string;
  63544. };
  63545. }
  63546. declare module BABYLON {
  63547. /**
  63548. * The grid materials allows you to wrap any shape with a grid.
  63549. * Colors are customizable.
  63550. */
  63551. export class GridMaterial extends BABYLON.PushMaterial {
  63552. /**
  63553. * Main color of the grid (e.g. between lines)
  63554. */
  63555. mainColor: BABYLON.Color3;
  63556. /**
  63557. * Color of the grid lines.
  63558. */
  63559. lineColor: BABYLON.Color3;
  63560. /**
  63561. * The scale of the grid compared to unit.
  63562. */
  63563. gridRatio: number;
  63564. /**
  63565. * Allows setting an offset for the grid lines.
  63566. */
  63567. gridOffset: BABYLON.Vector3;
  63568. /**
  63569. * The frequency of thicker lines.
  63570. */
  63571. majorUnitFrequency: number;
  63572. /**
  63573. * The visibility of minor units in the grid.
  63574. */
  63575. minorUnitVisibility: number;
  63576. /**
  63577. * The grid opacity outside of the lines.
  63578. */
  63579. opacity: number;
  63580. /**
  63581. * Determine RBG output is premultiplied by alpha value.
  63582. */
  63583. preMultiplyAlpha: boolean;
  63584. private _opacityTexture;
  63585. opacityTexture: BABYLON.BaseTexture;
  63586. private _gridControl;
  63587. private _renderId;
  63588. /**
  63589. * constructor
  63590. * @param name The name given to the material in order to identify it afterwards.
  63591. * @param scene The scene the material is used in.
  63592. */
  63593. constructor(name: string, scene: BABYLON.Scene);
  63594. /**
  63595. * Returns wehter or not the grid requires alpha blending.
  63596. */
  63597. needAlphaBlending(): boolean;
  63598. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  63599. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63600. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63601. /**
  63602. * Dispose the material and its associated resources.
  63603. * @param forceDisposeEffect will also dispose the used effect when true
  63604. */
  63605. dispose(forceDisposeEffect?: boolean): void;
  63606. clone(name: string): GridMaterial;
  63607. serialize(): any;
  63608. getClassName(): string;
  63609. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  63610. }
  63611. }
  63612. declare module BABYLON {
  63613. /** @hidden */
  63614. export var lavaPixelShader: {
  63615. name: string;
  63616. shader: string;
  63617. };
  63618. }
  63619. declare module BABYLON {
  63620. /** @hidden */
  63621. export var lavaVertexShader: {
  63622. name: string;
  63623. shader: string;
  63624. };
  63625. }
  63626. declare module BABYLON {
  63627. export class LavaMaterial extends BABYLON.PushMaterial {
  63628. private _diffuseTexture;
  63629. diffuseTexture: BABYLON.BaseTexture;
  63630. noiseTexture: BABYLON.BaseTexture;
  63631. fogColor: BABYLON.Color3;
  63632. speed: number;
  63633. movingSpeed: number;
  63634. lowFrequencySpeed: number;
  63635. fogDensity: number;
  63636. private _lastTime;
  63637. diffuseColor: BABYLON.Color3;
  63638. private _disableLighting;
  63639. disableLighting: boolean;
  63640. private _unlit;
  63641. unlit: boolean;
  63642. private _maxSimultaneousLights;
  63643. maxSimultaneousLights: number;
  63644. private _scaledDiffuse;
  63645. private _renderId;
  63646. constructor(name: string, scene: BABYLON.Scene);
  63647. needAlphaBlending(): boolean;
  63648. needAlphaTesting(): boolean;
  63649. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63650. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63651. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63652. getAnimatables(): BABYLON.IAnimatable[];
  63653. getActiveTextures(): BABYLON.BaseTexture[];
  63654. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63655. dispose(forceDisposeEffect?: boolean): void;
  63656. clone(name: string): LavaMaterial;
  63657. serialize(): any;
  63658. getClassName(): string;
  63659. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  63660. }
  63661. }
  63662. declare module BABYLON {
  63663. /** @hidden */
  63664. export var mixPixelShader: {
  63665. name: string;
  63666. shader: string;
  63667. };
  63668. }
  63669. declare module BABYLON {
  63670. /** @hidden */
  63671. export var mixVertexShader: {
  63672. name: string;
  63673. shader: string;
  63674. };
  63675. }
  63676. declare module BABYLON {
  63677. export class MixMaterial extends BABYLON.PushMaterial {
  63678. /**
  63679. * Mix textures
  63680. */
  63681. private _mixTexture1;
  63682. mixTexture1: BABYLON.BaseTexture;
  63683. private _mixTexture2;
  63684. mixTexture2: BABYLON.BaseTexture;
  63685. /**
  63686. * Diffuse textures
  63687. */
  63688. private _diffuseTexture1;
  63689. diffuseTexture1: BABYLON.Texture;
  63690. private _diffuseTexture2;
  63691. diffuseTexture2: BABYLON.Texture;
  63692. private _diffuseTexture3;
  63693. diffuseTexture3: BABYLON.Texture;
  63694. private _diffuseTexture4;
  63695. diffuseTexture4: BABYLON.Texture;
  63696. private _diffuseTexture5;
  63697. diffuseTexture5: BABYLON.Texture;
  63698. private _diffuseTexture6;
  63699. diffuseTexture6: BABYLON.Texture;
  63700. private _diffuseTexture7;
  63701. diffuseTexture7: BABYLON.Texture;
  63702. private _diffuseTexture8;
  63703. diffuseTexture8: BABYLON.Texture;
  63704. /**
  63705. * Uniforms
  63706. */
  63707. diffuseColor: BABYLON.Color3;
  63708. specularColor: BABYLON.Color3;
  63709. specularPower: number;
  63710. private _disableLighting;
  63711. disableLighting: boolean;
  63712. private _maxSimultaneousLights;
  63713. maxSimultaneousLights: number;
  63714. private _renderId;
  63715. constructor(name: string, scene: BABYLON.Scene);
  63716. needAlphaBlending(): boolean;
  63717. needAlphaTesting(): boolean;
  63718. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63719. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63720. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63721. getAnimatables(): BABYLON.IAnimatable[];
  63722. getActiveTextures(): BABYLON.BaseTexture[];
  63723. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63724. dispose(forceDisposeEffect?: boolean): void;
  63725. clone(name: string): MixMaterial;
  63726. serialize(): any;
  63727. getClassName(): string;
  63728. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  63729. }
  63730. }
  63731. declare module BABYLON {
  63732. /** @hidden */
  63733. export var normalPixelShader: {
  63734. name: string;
  63735. shader: string;
  63736. };
  63737. }
  63738. declare module BABYLON {
  63739. /** @hidden */
  63740. export var normalVertexShader: {
  63741. name: string;
  63742. shader: string;
  63743. };
  63744. }
  63745. declare module BABYLON {
  63746. export class NormalMaterial extends BABYLON.PushMaterial {
  63747. private _diffuseTexture;
  63748. diffuseTexture: BABYLON.BaseTexture;
  63749. diffuseColor: BABYLON.Color3;
  63750. private _disableLighting;
  63751. disableLighting: boolean;
  63752. private _maxSimultaneousLights;
  63753. maxSimultaneousLights: number;
  63754. private _renderId;
  63755. constructor(name: string, scene: BABYLON.Scene);
  63756. needAlphaBlending(): boolean;
  63757. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  63758. needAlphaTesting(): boolean;
  63759. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63760. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63761. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63762. getAnimatables(): BABYLON.IAnimatable[];
  63763. getActiveTextures(): BABYLON.BaseTexture[];
  63764. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63765. dispose(forceDisposeEffect?: boolean): void;
  63766. clone(name: string): NormalMaterial;
  63767. serialize(): any;
  63768. getClassName(): string;
  63769. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  63770. }
  63771. }
  63772. declare module BABYLON {
  63773. /** @hidden */
  63774. export var shadowOnlyPixelShader: {
  63775. name: string;
  63776. shader: string;
  63777. };
  63778. }
  63779. declare module BABYLON {
  63780. /** @hidden */
  63781. export var shadowOnlyVertexShader: {
  63782. name: string;
  63783. shader: string;
  63784. };
  63785. }
  63786. declare module BABYLON {
  63787. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  63788. private _renderId;
  63789. private _activeLight;
  63790. constructor(name: string, scene: BABYLON.Scene);
  63791. shadowColor: BABYLON.Color3;
  63792. needAlphaBlending(): boolean;
  63793. needAlphaTesting(): boolean;
  63794. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63795. activeLight: BABYLON.IShadowLight;
  63796. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63797. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63798. clone(name: string): ShadowOnlyMaterial;
  63799. serialize(): any;
  63800. getClassName(): string;
  63801. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  63802. }
  63803. }
  63804. declare module BABYLON {
  63805. /** @hidden */
  63806. export var simplePixelShader: {
  63807. name: string;
  63808. shader: string;
  63809. };
  63810. }
  63811. declare module BABYLON {
  63812. /** @hidden */
  63813. export var simpleVertexShader: {
  63814. name: string;
  63815. shader: string;
  63816. };
  63817. }
  63818. declare module BABYLON {
  63819. export class SimpleMaterial extends BABYLON.PushMaterial {
  63820. private _diffuseTexture;
  63821. diffuseTexture: BABYLON.BaseTexture;
  63822. diffuseColor: BABYLON.Color3;
  63823. private _disableLighting;
  63824. disableLighting: boolean;
  63825. private _maxSimultaneousLights;
  63826. maxSimultaneousLights: number;
  63827. private _renderId;
  63828. constructor(name: string, scene: BABYLON.Scene);
  63829. needAlphaBlending(): boolean;
  63830. needAlphaTesting(): boolean;
  63831. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63832. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63833. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63834. getAnimatables(): BABYLON.IAnimatable[];
  63835. getActiveTextures(): BABYLON.BaseTexture[];
  63836. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63837. dispose(forceDisposeEffect?: boolean): void;
  63838. clone(name: string): SimpleMaterial;
  63839. serialize(): any;
  63840. getClassName(): string;
  63841. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  63842. }
  63843. }
  63844. declare module BABYLON {
  63845. /** @hidden */
  63846. export var skyPixelShader: {
  63847. name: string;
  63848. shader: string;
  63849. };
  63850. }
  63851. declare module BABYLON {
  63852. /** @hidden */
  63853. export var skyVertexShader: {
  63854. name: string;
  63855. shader: string;
  63856. };
  63857. }
  63858. declare module BABYLON {
  63859. /**
  63860. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  63861. * @see https://doc.babylonjs.com/extensions/sky
  63862. */
  63863. export class SkyMaterial extends BABYLON.PushMaterial {
  63864. /**
  63865. * Defines the overall luminance of sky in interval ]0, 1[.
  63866. */
  63867. luminance: number;
  63868. /**
  63869. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  63870. */
  63871. turbidity: number;
  63872. /**
  63873. * Defines the sky appearance (light intensity).
  63874. */
  63875. rayleigh: number;
  63876. /**
  63877. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  63878. */
  63879. mieCoefficient: number;
  63880. /**
  63881. * Defines the amount of haze particles following the Mie scattering theory.
  63882. */
  63883. mieDirectionalG: number;
  63884. /**
  63885. * Defines the distance of the sun according to the active scene camera.
  63886. */
  63887. distance: number;
  63888. /**
  63889. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  63890. * "inclined".
  63891. */
  63892. inclination: number;
  63893. /**
  63894. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  63895. * an object direction and a reference direction.
  63896. */
  63897. azimuth: number;
  63898. /**
  63899. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  63900. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  63901. */
  63902. sunPosition: BABYLON.Vector3;
  63903. /**
  63904. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  63905. * .sunPosition property.
  63906. */
  63907. useSunPosition: boolean;
  63908. /**
  63909. * Defines an offset vector used to get a horizon offset.
  63910. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  63911. */
  63912. cameraOffset: BABYLON.Vector3;
  63913. private _cameraPosition;
  63914. private _renderId;
  63915. /**
  63916. * Instantiates a new sky material.
  63917. * This material allows to create dynamic and texture free
  63918. * effects for skyboxes by taking care of the atmosphere state.
  63919. * @see https://doc.babylonjs.com/extensions/sky
  63920. * @param name Define the name of the material in the scene
  63921. * @param scene Define the scene the material belong to
  63922. */
  63923. constructor(name: string, scene: BABYLON.Scene);
  63924. /**
  63925. * Specifies if the material will require alpha blending
  63926. * @returns a boolean specifying if alpha blending is needed
  63927. */
  63928. needAlphaBlending(): boolean;
  63929. /**
  63930. * Specifies if this material should be rendered in alpha test mode
  63931. * @returns false as the sky material doesn't need alpha testing.
  63932. */
  63933. needAlphaTesting(): boolean;
  63934. /**
  63935. * Get the texture used for alpha test purpose.
  63936. * @returns null as the sky material has no texture.
  63937. */
  63938. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63939. /**
  63940. * Get if the submesh is ready to be used and all its information available.
  63941. * Child classes can use it to update shaders
  63942. * @param mesh defines the mesh to check
  63943. * @param subMesh defines which submesh to check
  63944. * @param useInstances specifies that instances should be used
  63945. * @returns a boolean indicating that the submesh is ready or not
  63946. */
  63947. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63948. /**
  63949. * Binds the submesh to this material by preparing the effect and shader to draw
  63950. * @param world defines the world transformation matrix
  63951. * @param mesh defines the mesh containing the submesh
  63952. * @param subMesh defines the submesh to bind the material to
  63953. */
  63954. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63955. /**
  63956. * Get the list of animatables in the material.
  63957. * @returns the list of animatables object used in the material
  63958. */
  63959. getAnimatables(): BABYLON.IAnimatable[];
  63960. /**
  63961. * Disposes the material
  63962. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  63963. */
  63964. dispose(forceDisposeEffect?: boolean): void;
  63965. /**
  63966. * Makes a duplicate of the material, and gives it a new name
  63967. * @param name defines the new name for the duplicated material
  63968. * @returns the cloned material
  63969. */
  63970. clone(name: string): SkyMaterial;
  63971. /**
  63972. * Serializes this material in a JSON representation
  63973. * @returns the serialized material object
  63974. */
  63975. serialize(): any;
  63976. /**
  63977. * Gets the current class name of the material e.g. "SkyMaterial"
  63978. * Mainly use in serialization.
  63979. * @returns the class name
  63980. */
  63981. getClassName(): string;
  63982. /**
  63983. * Creates a sky material from parsed material data
  63984. * @param source defines the JSON representation of the material
  63985. * @param scene defines the hosting scene
  63986. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63987. * @returns a new sky material
  63988. */
  63989. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  63990. }
  63991. }
  63992. declare module BABYLON {
  63993. /** @hidden */
  63994. export var terrainPixelShader: {
  63995. name: string;
  63996. shader: string;
  63997. };
  63998. }
  63999. declare module BABYLON {
  64000. /** @hidden */
  64001. export var terrainVertexShader: {
  64002. name: string;
  64003. shader: string;
  64004. };
  64005. }
  64006. declare module BABYLON {
  64007. export class TerrainMaterial extends BABYLON.PushMaterial {
  64008. private _mixTexture;
  64009. mixTexture: BABYLON.BaseTexture;
  64010. private _diffuseTexture1;
  64011. diffuseTexture1: BABYLON.Texture;
  64012. private _diffuseTexture2;
  64013. diffuseTexture2: BABYLON.Texture;
  64014. private _diffuseTexture3;
  64015. diffuseTexture3: BABYLON.Texture;
  64016. private _bumpTexture1;
  64017. bumpTexture1: BABYLON.Texture;
  64018. private _bumpTexture2;
  64019. bumpTexture2: BABYLON.Texture;
  64020. private _bumpTexture3;
  64021. bumpTexture3: BABYLON.Texture;
  64022. diffuseColor: BABYLON.Color3;
  64023. specularColor: BABYLON.Color3;
  64024. specularPower: number;
  64025. private _disableLighting;
  64026. disableLighting: boolean;
  64027. private _maxSimultaneousLights;
  64028. maxSimultaneousLights: number;
  64029. private _renderId;
  64030. constructor(name: string, scene: BABYLON.Scene);
  64031. needAlphaBlending(): boolean;
  64032. needAlphaTesting(): boolean;
  64033. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64034. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64035. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64036. getAnimatables(): BABYLON.IAnimatable[];
  64037. getActiveTextures(): BABYLON.BaseTexture[];
  64038. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64039. dispose(forceDisposeEffect?: boolean): void;
  64040. clone(name: string): TerrainMaterial;
  64041. serialize(): any;
  64042. getClassName(): string;
  64043. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  64044. }
  64045. }
  64046. declare module BABYLON {
  64047. /** @hidden */
  64048. export var triplanarPixelShader: {
  64049. name: string;
  64050. shader: string;
  64051. };
  64052. }
  64053. declare module BABYLON {
  64054. /** @hidden */
  64055. export var triplanarVertexShader: {
  64056. name: string;
  64057. shader: string;
  64058. };
  64059. }
  64060. declare module BABYLON {
  64061. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  64062. mixTexture: BABYLON.BaseTexture;
  64063. private _diffuseTextureX;
  64064. diffuseTextureX: BABYLON.BaseTexture;
  64065. private _diffuseTextureY;
  64066. diffuseTextureY: BABYLON.BaseTexture;
  64067. private _diffuseTextureZ;
  64068. diffuseTextureZ: BABYLON.BaseTexture;
  64069. private _normalTextureX;
  64070. normalTextureX: BABYLON.BaseTexture;
  64071. private _normalTextureY;
  64072. normalTextureY: BABYLON.BaseTexture;
  64073. private _normalTextureZ;
  64074. normalTextureZ: BABYLON.BaseTexture;
  64075. tileSize: number;
  64076. diffuseColor: BABYLON.Color3;
  64077. specularColor: BABYLON.Color3;
  64078. specularPower: number;
  64079. private _disableLighting;
  64080. disableLighting: boolean;
  64081. private _maxSimultaneousLights;
  64082. maxSimultaneousLights: number;
  64083. private _renderId;
  64084. constructor(name: string, scene: BABYLON.Scene);
  64085. needAlphaBlending(): boolean;
  64086. needAlphaTesting(): boolean;
  64087. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64088. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64089. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64090. getAnimatables(): BABYLON.IAnimatable[];
  64091. getActiveTextures(): BABYLON.BaseTexture[];
  64092. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64093. dispose(forceDisposeEffect?: boolean): void;
  64094. clone(name: string): TriPlanarMaterial;
  64095. serialize(): any;
  64096. getClassName(): string;
  64097. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  64098. }
  64099. }
  64100. declare module BABYLON {
  64101. /** @hidden */
  64102. export var waterPixelShader: {
  64103. name: string;
  64104. shader: string;
  64105. };
  64106. }
  64107. declare module BABYLON {
  64108. /** @hidden */
  64109. export var waterVertexShader: {
  64110. name: string;
  64111. shader: string;
  64112. };
  64113. }
  64114. declare module BABYLON {
  64115. export class WaterMaterial extends BABYLON.PushMaterial {
  64116. renderTargetSize: BABYLON.Vector2;
  64117. private _bumpTexture;
  64118. bumpTexture: BABYLON.BaseTexture;
  64119. diffuseColor: BABYLON.Color3;
  64120. specularColor: BABYLON.Color3;
  64121. specularPower: number;
  64122. private _disableLighting;
  64123. disableLighting: boolean;
  64124. private _maxSimultaneousLights;
  64125. maxSimultaneousLights: number;
  64126. /**
  64127. * @param {number}: Represents the wind force
  64128. */
  64129. windForce: number;
  64130. /**
  64131. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  64132. */
  64133. windDirection: BABYLON.Vector2;
  64134. /**
  64135. * @param {number}: Wave height, represents the height of the waves
  64136. */
  64137. waveHeight: number;
  64138. /**
  64139. * @param {number}: Bump height, represents the bump height related to the bump map
  64140. */
  64141. bumpHeight: number;
  64142. /**
  64143. * @param {boolean}: Add a smaller moving bump to less steady waves.
  64144. */
  64145. private _bumpSuperimpose;
  64146. bumpSuperimpose: boolean;
  64147. /**
  64148. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  64149. */
  64150. private _fresnelSeparate;
  64151. fresnelSeparate: boolean;
  64152. /**
  64153. * @param {boolean}: bump Waves modify the reflection.
  64154. */
  64155. private _bumpAffectsReflection;
  64156. bumpAffectsReflection: boolean;
  64157. /**
  64158. * @param {number}: The water color blended with the refraction (near)
  64159. */
  64160. waterColor: BABYLON.Color3;
  64161. /**
  64162. * @param {number}: The blend factor related to the water color
  64163. */
  64164. colorBlendFactor: number;
  64165. /**
  64166. * @param {number}: The water color blended with the reflection (far)
  64167. */
  64168. waterColor2: BABYLON.Color3;
  64169. /**
  64170. * @param {number}: The blend factor related to the water color (reflection, far)
  64171. */
  64172. colorBlendFactor2: number;
  64173. /**
  64174. * @param {number}: Represents the maximum length of a wave
  64175. */
  64176. waveLength: number;
  64177. /**
  64178. * @param {number}: Defines the waves speed
  64179. */
  64180. waveSpeed: number;
  64181. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  64182. private _mesh;
  64183. private _refractionRTT;
  64184. private _reflectionRTT;
  64185. private _reflectionTransform;
  64186. private _lastTime;
  64187. private _lastDeltaTime;
  64188. private _renderId;
  64189. private _useLogarithmicDepth;
  64190. private _waitingRenderList;
  64191. /**
  64192. * Gets a boolean indicating that current material needs to register RTT
  64193. */
  64194. readonly hasRenderTargetTextures: boolean;
  64195. /**
  64196. * Constructor
  64197. */
  64198. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  64199. useLogarithmicDepth: boolean;
  64200. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  64201. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  64202. addToRenderList(node: any): void;
  64203. enableRenderTargets(enable: boolean): void;
  64204. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  64205. readonly renderTargetsEnabled: boolean;
  64206. needAlphaBlending(): boolean;
  64207. needAlphaTesting(): boolean;
  64208. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64209. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64210. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64211. private _createRenderTargets;
  64212. getAnimatables(): BABYLON.IAnimatable[];
  64213. getActiveTextures(): BABYLON.BaseTexture[];
  64214. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64215. dispose(forceDisposeEffect?: boolean): void;
  64216. clone(name: string): WaterMaterial;
  64217. serialize(): any;
  64218. getClassName(): string;
  64219. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  64220. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  64221. }
  64222. }
  64223. declare module BABYLON {
  64224. /** @hidden */
  64225. export var asciiartPixelShader: {
  64226. name: string;
  64227. shader: string;
  64228. };
  64229. }
  64230. declare module BABYLON {
  64231. /**
  64232. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  64233. *
  64234. * It basically takes care rendering the font front the given font size to a texture.
  64235. * This is used later on in the postprocess.
  64236. */
  64237. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  64238. private _font;
  64239. private _text;
  64240. private _charSize;
  64241. /**
  64242. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  64243. */
  64244. readonly charSize: number;
  64245. /**
  64246. * Create a new instance of the Ascii Art FontTexture class
  64247. * @param name the name of the texture
  64248. * @param font the font to use, use the W3C CSS notation
  64249. * @param text the caracter set to use in the rendering.
  64250. * @param scene the scene that owns the texture
  64251. */
  64252. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  64253. /**
  64254. * Gets the max char width of a font.
  64255. * @param font the font to use, use the W3C CSS notation
  64256. * @return the max char width
  64257. */
  64258. private getFontWidth;
  64259. /**
  64260. * Gets the max char height of a font.
  64261. * @param font the font to use, use the W3C CSS notation
  64262. * @return the max char height
  64263. */
  64264. private getFontHeight;
  64265. /**
  64266. * Clones the current AsciiArtTexture.
  64267. * @return the clone of the texture.
  64268. */
  64269. clone(): AsciiArtFontTexture;
  64270. /**
  64271. * Parses a json object representing the texture and returns an instance of it.
  64272. * @param source the source JSON representation
  64273. * @param scene the scene to create the texture for
  64274. * @return the parsed texture
  64275. */
  64276. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  64277. }
  64278. /**
  64279. * Option available in the Ascii Art Post Process.
  64280. */
  64281. export interface IAsciiArtPostProcessOptions {
  64282. /**
  64283. * The font to use following the w3c font definition.
  64284. */
  64285. font?: string;
  64286. /**
  64287. * The character set to use in the postprocess.
  64288. */
  64289. characterSet?: string;
  64290. /**
  64291. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  64292. * This number is defined between 0 and 1;
  64293. */
  64294. mixToTile?: number;
  64295. /**
  64296. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  64297. * This number is defined between 0 and 1;
  64298. */
  64299. mixToNormal?: number;
  64300. }
  64301. /**
  64302. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  64303. *
  64304. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64305. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  64306. */
  64307. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  64308. /**
  64309. * The font texture used to render the char in the post process.
  64310. */
  64311. private _asciiArtFontTexture;
  64312. /**
  64313. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  64314. * This number is defined between 0 and 1;
  64315. */
  64316. mixToTile: number;
  64317. /**
  64318. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  64319. * This number is defined between 0 and 1;
  64320. */
  64321. mixToNormal: number;
  64322. /**
  64323. * Instantiates a new Ascii Art Post Process.
  64324. * @param name the name to give to the postprocess
  64325. * @camera the camera to apply the post process to.
  64326. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  64327. */
  64328. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  64329. }
  64330. }
  64331. declare module BABYLON {
  64332. /** @hidden */
  64333. export var digitalrainPixelShader: {
  64334. name: string;
  64335. shader: string;
  64336. };
  64337. }
  64338. declare module BABYLON {
  64339. /**
  64340. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  64341. *
  64342. * It basically takes care rendering the font front the given font size to a texture.
  64343. * This is used later on in the postprocess.
  64344. */
  64345. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  64346. private _font;
  64347. private _text;
  64348. private _charSize;
  64349. /**
  64350. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  64351. */
  64352. readonly charSize: number;
  64353. /**
  64354. * Create a new instance of the Digital Rain FontTexture class
  64355. * @param name the name of the texture
  64356. * @param font the font to use, use the W3C CSS notation
  64357. * @param text the caracter set to use in the rendering.
  64358. * @param scene the scene that owns the texture
  64359. */
  64360. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  64361. /**
  64362. * Gets the max char width of a font.
  64363. * @param font the font to use, use the W3C CSS notation
  64364. * @return the max char width
  64365. */
  64366. private getFontWidth;
  64367. /**
  64368. * Gets the max char height of a font.
  64369. * @param font the font to use, use the W3C CSS notation
  64370. * @return the max char height
  64371. */
  64372. private getFontHeight;
  64373. /**
  64374. * Clones the current DigitalRainFontTexture.
  64375. * @return the clone of the texture.
  64376. */
  64377. clone(): DigitalRainFontTexture;
  64378. /**
  64379. * Parses a json object representing the texture and returns an instance of it.
  64380. * @param source the source JSON representation
  64381. * @param scene the scene to create the texture for
  64382. * @return the parsed texture
  64383. */
  64384. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  64385. }
  64386. /**
  64387. * Option available in the Digital Rain Post Process.
  64388. */
  64389. export interface IDigitalRainPostProcessOptions {
  64390. /**
  64391. * The font to use following the w3c font definition.
  64392. */
  64393. font?: string;
  64394. /**
  64395. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  64396. * This number is defined between 0 and 1;
  64397. */
  64398. mixToTile?: number;
  64399. /**
  64400. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  64401. * This number is defined between 0 and 1;
  64402. */
  64403. mixToNormal?: number;
  64404. }
  64405. /**
  64406. * DigitalRainPostProcess helps rendering everithing in digital rain.
  64407. *
  64408. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64409. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  64410. */
  64411. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  64412. /**
  64413. * The font texture used to render the char in the post process.
  64414. */
  64415. private _digitalRainFontTexture;
  64416. /**
  64417. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  64418. * This number is defined between 0 and 1;
  64419. */
  64420. mixToTile: number;
  64421. /**
  64422. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  64423. * This number is defined between 0 and 1;
  64424. */
  64425. mixToNormal: number;
  64426. /**
  64427. * Instantiates a new Digital Rain Post Process.
  64428. * @param name the name to give to the postprocess
  64429. * @camera the camera to apply the post process to.
  64430. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  64431. */
  64432. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  64433. }
  64434. }
  64435. declare module BABYLON {
  64436. /** @hidden */
  64437. export var oceanPostProcessPixelShader: {
  64438. name: string;
  64439. shader: string;
  64440. };
  64441. }
  64442. declare module BABYLON {
  64443. /**
  64444. * Option available in the Ocean Post Process.
  64445. */
  64446. export interface IOceanPostProcessOptions {
  64447. /**
  64448. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  64449. */
  64450. reflectionSize?: number | {
  64451. width: number;
  64452. height: number;
  64453. } | {
  64454. ratio: number;
  64455. };
  64456. /**
  64457. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  64458. */
  64459. refractionSize?: number | {
  64460. width: number;
  64461. height: number;
  64462. } | {
  64463. ratio: number;
  64464. };
  64465. }
  64466. /**
  64467. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  64468. *
  64469. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64470. * Example usage:
  64471. * var pp = new OceanPostProcess("myOcean", camera);
  64472. * pp.reflectionEnabled = true;
  64473. * pp.refractionEnabled = true;
  64474. */
  64475. export class OceanPostProcess extends BABYLON.PostProcess {
  64476. /**
  64477. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  64478. */
  64479. /**
  64480. * Sets weither or not the real-time reflection is enabled on the ocean.
  64481. * Is set to true, the reflection mirror texture will be used as reflection texture.
  64482. */
  64483. reflectionEnabled: boolean;
  64484. /**
  64485. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  64486. */
  64487. /**
  64488. * Sets weither or not the real-time refraction is enabled on the ocean.
  64489. * Is set to true, the refraction render target texture will be used as refraction texture.
  64490. */
  64491. refractionEnabled: boolean;
  64492. /**
  64493. * Gets wether or not the post-processes is supported by the running hardware.
  64494. * This requires draw buffer supports.
  64495. */
  64496. readonly isSupported: boolean;
  64497. /**
  64498. * This is the reflection mirror texture used to display reflections on the ocean.
  64499. * By default, render list is empty.
  64500. */
  64501. reflectionTexture: BABYLON.MirrorTexture;
  64502. /**
  64503. * This is the refraction render target texture used to display refraction on the ocean.
  64504. * By default, render list is empty.
  64505. */
  64506. refractionTexture: BABYLON.RenderTargetTexture;
  64507. private _time;
  64508. private _cameraRotation;
  64509. private _cameraViewMatrix;
  64510. private _reflectionEnabled;
  64511. private _refractionEnabled;
  64512. private _geometryRenderer;
  64513. /**
  64514. * Instantiates a new Ocean Post Process.
  64515. * @param name the name to give to the postprocess.
  64516. * @camera the camera to apply the post process to.
  64517. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  64518. */
  64519. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  64520. /**
  64521. * Returns the appropriate defines according to the current configuration.
  64522. */
  64523. private _getDefines;
  64524. /**
  64525. * Computes the current camera rotation as the shader requires a camera rotation.
  64526. */
  64527. private _computeCameraRotation;
  64528. }
  64529. }
  64530. declare module BABYLON {
  64531. /** @hidden */
  64532. export var brickProceduralTexturePixelShader: {
  64533. name: string;
  64534. shader: string;
  64535. };
  64536. }
  64537. declare module BABYLON {
  64538. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  64539. private _numberOfBricksHeight;
  64540. private _numberOfBricksWidth;
  64541. private _jointColor;
  64542. private _brickColor;
  64543. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64544. updateShaderUniforms(): void;
  64545. numberOfBricksHeight: number;
  64546. numberOfBricksWidth: number;
  64547. jointColor: BABYLON.Color3;
  64548. brickColor: BABYLON.Color3;
  64549. /**
  64550. * Serializes this brick procedural texture
  64551. * @returns a serialized brick procedural texture object
  64552. */
  64553. serialize(): any;
  64554. /**
  64555. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  64556. * @param parsedTexture defines parsed texture data
  64557. * @param scene defines the current scene
  64558. * @param rootUrl defines the root URL containing brick procedural texture information
  64559. * @returns a parsed Brick Procedural BABYLON.Texture
  64560. */
  64561. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  64562. }
  64563. }
  64564. declare module BABYLON {
  64565. /** @hidden */
  64566. export var cloudProceduralTexturePixelShader: {
  64567. name: string;
  64568. shader: string;
  64569. };
  64570. }
  64571. declare module BABYLON {
  64572. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  64573. private _skyColor;
  64574. private _cloudColor;
  64575. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64576. updateShaderUniforms(): void;
  64577. skyColor: BABYLON.Color4;
  64578. cloudColor: BABYLON.Color4;
  64579. /**
  64580. * Serializes this cloud procedural texture
  64581. * @returns a serialized cloud procedural texture object
  64582. */
  64583. serialize(): any;
  64584. /**
  64585. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  64586. * @param parsedTexture defines parsed texture data
  64587. * @param scene defines the current scene
  64588. * @param rootUrl defines the root URL containing cloud procedural texture information
  64589. * @returns a parsed Cloud Procedural BABYLON.Texture
  64590. */
  64591. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  64592. }
  64593. }
  64594. declare module BABYLON {
  64595. /** @hidden */
  64596. export var fireProceduralTexturePixelShader: {
  64597. name: string;
  64598. shader: string;
  64599. };
  64600. }
  64601. declare module BABYLON {
  64602. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  64603. private _time;
  64604. private _speed;
  64605. private _autoGenerateTime;
  64606. private _fireColors;
  64607. private _alphaThreshold;
  64608. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64609. updateShaderUniforms(): void;
  64610. render(useCameraPostProcess?: boolean): void;
  64611. static readonly PurpleFireColors: BABYLON.Color3[];
  64612. static readonly GreenFireColors: BABYLON.Color3[];
  64613. static readonly RedFireColors: BABYLON.Color3[];
  64614. static readonly BlueFireColors: BABYLON.Color3[];
  64615. autoGenerateTime: boolean;
  64616. fireColors: BABYLON.Color3[];
  64617. time: number;
  64618. speed: BABYLON.Vector2;
  64619. alphaThreshold: number;
  64620. /**
  64621. * Serializes this fire procedural texture
  64622. * @returns a serialized fire procedural texture object
  64623. */
  64624. serialize(): any;
  64625. /**
  64626. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  64627. * @param parsedTexture defines parsed texture data
  64628. * @param scene defines the current scene
  64629. * @param rootUrl defines the root URL containing fire procedural texture information
  64630. * @returns a parsed Fire Procedural BABYLON.Texture
  64631. */
  64632. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  64633. }
  64634. }
  64635. declare module BABYLON {
  64636. /** @hidden */
  64637. export var grassProceduralTexturePixelShader: {
  64638. name: string;
  64639. shader: string;
  64640. };
  64641. }
  64642. declare module BABYLON {
  64643. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  64644. private _grassColors;
  64645. private _groundColor;
  64646. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64647. updateShaderUniforms(): void;
  64648. grassColors: BABYLON.Color3[];
  64649. groundColor: BABYLON.Color3;
  64650. /**
  64651. * Serializes this grass procedural texture
  64652. * @returns a serialized grass procedural texture object
  64653. */
  64654. serialize(): any;
  64655. /**
  64656. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  64657. * @param parsedTexture defines parsed texture data
  64658. * @param scene defines the current scene
  64659. * @param rootUrl defines the root URL containing grass procedural texture information
  64660. * @returns a parsed Grass Procedural BABYLON.Texture
  64661. */
  64662. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  64663. }
  64664. }
  64665. declare module BABYLON {
  64666. /** @hidden */
  64667. export var marbleProceduralTexturePixelShader: {
  64668. name: string;
  64669. shader: string;
  64670. };
  64671. }
  64672. declare module BABYLON {
  64673. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  64674. private _numberOfTilesHeight;
  64675. private _numberOfTilesWidth;
  64676. private _amplitude;
  64677. private _jointColor;
  64678. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64679. updateShaderUniforms(): void;
  64680. numberOfTilesHeight: number;
  64681. amplitude: number;
  64682. numberOfTilesWidth: number;
  64683. jointColor: BABYLON.Color3;
  64684. /**
  64685. * Serializes this marble procedural texture
  64686. * @returns a serialized marble procedural texture object
  64687. */
  64688. serialize(): any;
  64689. /**
  64690. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  64691. * @param parsedTexture defines parsed texture data
  64692. * @param scene defines the current scene
  64693. * @param rootUrl defines the root URL containing marble procedural texture information
  64694. * @returns a parsed Marble Procedural BABYLON.Texture
  64695. */
  64696. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  64697. }
  64698. }
  64699. declare module BABYLON {
  64700. /** @hidden */
  64701. export var normalMapProceduralTexturePixelShader: {
  64702. name: string;
  64703. shader: string;
  64704. };
  64705. }
  64706. declare module BABYLON {
  64707. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  64708. private _baseTexture;
  64709. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64710. updateShaderUniforms(): void;
  64711. render(useCameraPostProcess?: boolean): void;
  64712. resize(size: any, generateMipMaps: any): void;
  64713. baseTexture: BABYLON.Texture;
  64714. /**
  64715. * Serializes this normal map procedural texture
  64716. * @returns a serialized normal map procedural texture object
  64717. */
  64718. serialize(): any;
  64719. /**
  64720. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  64721. * @param parsedTexture defines parsed texture data
  64722. * @param scene defines the current scene
  64723. * @param rootUrl defines the root URL containing normal map procedural texture information
  64724. * @returns a parsed Normal Map Procedural BABYLON.Texture
  64725. */
  64726. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  64727. }
  64728. }
  64729. declare module BABYLON {
  64730. /** @hidden */
  64731. export var perlinNoiseProceduralTexturePixelShader: {
  64732. name: string;
  64733. shader: string;
  64734. };
  64735. }
  64736. declare module BABYLON {
  64737. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  64738. time: number;
  64739. timeScale: number;
  64740. translationSpeed: number;
  64741. private _currentTranslation;
  64742. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64743. updateShaderUniforms(): void;
  64744. render(useCameraPostProcess?: boolean): void;
  64745. resize(size: any, generateMipMaps: any): void;
  64746. /**
  64747. * Serializes this perlin noise procedural texture
  64748. * @returns a serialized perlin noise procedural texture object
  64749. */
  64750. serialize(): any;
  64751. /**
  64752. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  64753. * @param parsedTexture defines parsed texture data
  64754. * @param scene defines the current scene
  64755. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  64756. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  64757. */
  64758. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  64759. }
  64760. }
  64761. declare module BABYLON {
  64762. /** @hidden */
  64763. export var roadProceduralTexturePixelShader: {
  64764. name: string;
  64765. shader: string;
  64766. };
  64767. }
  64768. declare module BABYLON {
  64769. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  64770. private _roadColor;
  64771. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64772. updateShaderUniforms(): void;
  64773. roadColor: BABYLON.Color3;
  64774. /**
  64775. * Serializes this road procedural texture
  64776. * @returns a serialized road procedural texture object
  64777. */
  64778. serialize(): any;
  64779. /**
  64780. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  64781. * @param parsedTexture defines parsed texture data
  64782. * @param scene defines the current scene
  64783. * @param rootUrl defines the root URL containing road procedural texture information
  64784. * @returns a parsed Road Procedural BABYLON.Texture
  64785. */
  64786. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  64787. }
  64788. }
  64789. declare module BABYLON {
  64790. /** @hidden */
  64791. export var starfieldProceduralTexturePixelShader: {
  64792. name: string;
  64793. shader: string;
  64794. };
  64795. }
  64796. declare module BABYLON {
  64797. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  64798. private _time;
  64799. private _alpha;
  64800. private _beta;
  64801. private _zoom;
  64802. private _formuparam;
  64803. private _stepsize;
  64804. private _tile;
  64805. private _brightness;
  64806. private _darkmatter;
  64807. private _distfading;
  64808. private _saturation;
  64809. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64810. updateShaderUniforms(): void;
  64811. time: number;
  64812. alpha: number;
  64813. beta: number;
  64814. formuparam: number;
  64815. stepsize: number;
  64816. zoom: number;
  64817. tile: number;
  64818. brightness: number;
  64819. darkmatter: number;
  64820. distfading: number;
  64821. saturation: number;
  64822. /**
  64823. * Serializes this starfield procedural texture
  64824. * @returns a serialized starfield procedural texture object
  64825. */
  64826. serialize(): any;
  64827. /**
  64828. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  64829. * @param parsedTexture defines parsed texture data
  64830. * @param scene defines the current scene
  64831. * @param rootUrl defines the root URL containing startfield procedural texture information
  64832. * @returns a parsed Starfield Procedural BABYLON.Texture
  64833. */
  64834. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  64835. }
  64836. }
  64837. declare module BABYLON {
  64838. /** @hidden */
  64839. export var woodProceduralTexturePixelShader: {
  64840. name: string;
  64841. shader: string;
  64842. };
  64843. }
  64844. declare module BABYLON {
  64845. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  64846. private _ampScale;
  64847. private _woodColor;
  64848. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64849. updateShaderUniforms(): void;
  64850. ampScale: number;
  64851. woodColor: BABYLON.Color3;
  64852. /**
  64853. * Serializes this wood procedural texture
  64854. * @returns a serialized wood procedural texture object
  64855. */
  64856. serialize(): any;
  64857. /**
  64858. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  64859. * @param parsedTexture defines parsed texture data
  64860. * @param scene defines the current scene
  64861. * @param rootUrl defines the root URL containing wood procedural texture information
  64862. * @returns a parsed Wood Procedural BABYLON.Texture
  64863. */
  64864. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  64865. }
  64866. }